| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- using System.Linq;
- using FMSAdmin.Data;
- using FMSAdmin.Entities;
- using Microsoft.Extensions.Logging;
- namespace FMSAdmin.Services {
- public class Investigation1CodeTypeService {
- private readonly ILogger<Investigation1CodeTypeService> _logger;
- private readonly FMSContext _context;
- public Investigation1CodeTypeService(
- ILogger<Investigation1CodeTypeService> logger,
- FMSContext context) {
- _logger = logger;
- _context = context;
- }
- public void Create(CmInvestigation1CodeType data) {
- _context.CmInvestigation1CodeType.Add(data);
- _context.SaveChanges();
- }
- public void Edit(int id, CmInvestigation1CodeType data) {
- var persist = _context.CmInvestigation1CodeType
- .Where(x => x.InvestigationTypeId == id).FirstOrDefault();
- if (persist == null) {
- throw new ServiceException("정보를 찾을 수 없습니다.");
- }
- persist.Name = data.Name;
- persist.IsUse = data.IsUse;
- _context.CmInvestigation1CodeType.Update(persist);
- _context.SaveChanges();
- }
- public void Delete(int id) {
- var data = _context.CmInvestigation1CodeType.First(x => x.InvestigationTypeId == id);
- _context.CmInvestigation1CodeType.Remove(data);
- _context.SaveChanges();
- }
- public IQueryable<CmInvestigation1CodeType> GetAll() {
- var query = _context.CmInvestigation1CodeType;
- return query;
- }
- public IQueryable<CmInvestigation1CodeType> Get(int id) {
- var data = _context.CmInvestigation1CodeType.Where(x => x.InvestigationTypeId == id);
- return data;
- }
- }
- }
|