예제 #1
0
        public WorkPermitStatus Create(WorkPermitStatus workPermitStatus)
        {
            if (string.IsNullOrEmpty(workPermitStatus.Status))
            {
                throw new ArgumentException("Equipment Name should not be empty ");
            }
            if (_context.WorkPermitStatus.Any(x => x.Status == workPermitStatus.Status))
            {
                throw new AppException("Equipment is already Exists");
            }
            _context.WorkPermitStatus.Add(workPermitStatus);
            _context.SaveChanges();

            return(workPermitStatus);
        }
예제 #2
0
        public WorkPermitStatus Update(WorkPermitStatus workPermitStatus, int id)
        {
            var workPermit = (from x in _context.WorkPermitStatus
                              where x.ID == workPermitStatus.ID
                              select x).FirstOrDefault();

            if (_context.WorkPermitStatus.Any(x => x.Status == workPermitStatus.Status))
            {
                throw new AppException("Status is already Exists");
            }
            if (string.IsNullOrEmpty(workPermitStatus.Status))
            {
                throw new ArgumentException("Status should not be Empty");
            }
            if (workPermit.ID == id)
            {
                workPermit.Status = workPermitStatus.Status;
            }
            _context.WorkPermitStatus.Update(workPermit);
            _context.SaveChanges();

            return(workPermit);
        }