public void AddPQClientAntecedentsField(AddClientFieldViewModel model) { try { if (model != null) { PQClientField entity = new PQClientField(); entity.ClientFieldRowID = model.ClientFieldRowID; entity.ClientRowID = model.ClientRowID; entity.CheckFamilyRowID = model.CheckFamilyRowID; entity.SubCheckRowID = model.SubCheckRowID; entity.AntecedentRowId = model.AntecedentRowId; entity.CADisplayName = model.CADisplayName; db.PQClientFields.Add(entity); } else { throw new Exception("Antecedent could not be blank!"); } } catch (Exception) { throw; } }
public void UpdatePQClientAntecedentsField(AddClientFieldViewModel model) { try { if (model != null && model.ClientRowID > 0) { db.PQClientFields.Single(c => c.ClientRowID == model.ClientRowID && c.CheckFamilyRowID == model.CheckFamilyRowID && c.SubCheckRowID == model.SubCheckRowID && c.AntecedentRowId == model.AntecedentRowId).CADisplayName = model.CADisplayName; } else { throw new Exception("Invalid Client Details!"); } } catch (Exception) { throw; } }
public void AddPQClientAntecedentsDefaultSelected(AddClientFieldViewModel model) { try { if (model != null) { List <PQClientField> entities = new List <PQClientField>(); PQClientField entity; var antecedent = db.MasterAntecedents.Where(a => (a.CheckFamilyRowID == model.CheckFamilyRowID || a.CheckFamilyRowID == 39) && a.IsSetDefault == 1 && a.Status == 1).ToList(); foreach (var item in antecedent) { if (!IsPQClientAntecedentsExist(model.ClientRowID, item.CheckFamilyRowID, model.SubCheckRowID, item.AntecedentRowId)) { entity = new PQClientField(); entity.ClientRowID = model.ClientRowID; entity.CheckFamilyRowID = item.CheckFamilyRowID; entity.SubCheckRowID = model.SubCheckRowID; entity.AntecedentRowId = item.AntecedentRowId; entity.CADisplayName = item.DisplayName; entities.Add(entity); } } db.PQClientFields.AddRange(entities); db.SaveChanges(); } else { throw new Exception("Client Id Mapped First!"); } } catch (Exception) { throw; } }