public MasterServiceCode GetServiceCodeByID(int ServiceCodeID, TokenModel token) { MasterServiceCode masterServiceCode = _context.MasterServiceCode .Where(x => x.Id == ServiceCodeID && x.IsDeleted == false && x.OrganizationID == token.OrganizationID) .Include(x => x.MasterServiceCodeModifiers) //.Where(f => f.MasterServiceCodeModifiers.Any(z => z.IsActive == true && z.IsDeleted == false)) .FirstOrDefault(); return(masterServiceCode); }
public MasterServiceCode AddMasterServiceCode(MasterServiceCode masterServiceCode) { try { _context.MasterServiceCode.Add(masterServiceCode); _context.SaveChanges(); } catch (Exception) { throw; } return(masterServiceCode); }
public MasterServiceCode UpdateServiceCode(MasterServiceCode serviceCode, DateTime CurrentDate) { try { if (serviceCode.MasterServiceCodeModifiers.Any(x => x.DeletedDate == CurrentDate || x.UpdatedDate == CurrentDate)) { foreach (var item in serviceCode.MasterServiceCodeModifiers.Where(x => x.UpdatedDate == CurrentDate || x.DeletedDate == CurrentDate)) { _context.Entry(item).State = EntityState.Modified; } } if (serviceCode.MasterServiceCodeModifiers.Any(x => x.CreatedDate == CurrentDate)) { _context.MasterServiceCodeModifiers.AddRange(serviceCode.MasterServiceCodeModifiers.Where(x => x.CreatedDate == CurrentDate)); } _context.Entry(serviceCode).State = EntityState.Modified; _context.SaveChanges(); } catch (Exception) { } return(serviceCode); }