public Exemption(Models.MasterExemption_DTO masterExemption, AdministrativeProperties_DTO administrationProperties) { try { Mapper.CreateMap<MasterExemption_DTO, Exemption>(); Mapper.Map(masterExemption, this); if (administrationProperties == null) administrationProperties = new Models.AdministrativeProperties_DTO(); Mapper.CreateMap<AdministrativeProperties_DTO, Exemption>() .ForMember(dest => dest.OnlineExemptionID, opt => opt.Ignore()) .ForMember(dest => dest.QuickrefID, opt => opt.Ignore()); Mapper.Map(administrationProperties, this); if (this.AssignedUserID != null) this.AssignedUser = User_DTO.Get(this.AssignedUserID); this.ExemptionTypes = new List<string>(); if (this.AF != null && this.AF == true) this.ExemptionTypes.Add("AF"); if (this.CDV != null && this.CDV == true) this.ExemptionTypes.Add("CDV"); if (this.CDVS != null && this.CDVS == true) this.ExemptionTypes.Add("CDVS"); if (this.CERTFORPART != null && this.CERTFORPART == true) this.ExemptionTypes.Add("CERTFORPART"); if (this.DP != null && this.DP == true) this.ExemptionTypes.Add("DP"); if (this.DV != null && this.DV == true) this.ExemptionTypes.Add("DV"); if (this.DVX != null && this.DVX == true) this.ExemptionTypes.Add("DVX"); if (this.DVXS != null && this.DVXS == true) this.ExemptionTypes.Add("DVXS"); if (this.DVXS2 != null && this.DVXS2 == true) this.ExemptionTypes.Add("DVXS2"); if (this.EXEMPT521 != null && this.EXEMPT521 == true) this.ExemptionTypes.Add("EXEMPT521"); if (this.HS != null && this.HS == true) this.ExemptionTypes.Add("HS"); if (this.OA != null && this.OA == true) this.ExemptionTypes.Add("OA"); if (this.OAS != null && this.OAS == true) this.ExemptionTypes.Add("OAS"); if (this.TCTC != null && this.TCTC == true) this.ExemptionTypes.Add("TCTC"); if (this.ExEffectiveDate != null) { this.ExemptionYear = this.ExEffectiveDate.Value.Year; } } catch (Exception ex) { throw ex; } }
public static AdministrativeProperties_DTO AddOrUpdate(AdministrativeProperties_DTO administrativeProperties) { try { if (administrativeProperties.AssignedUserID != null) administrativeProperties.AssignedUserID = (administrativeProperties.AssignedUserID <= 0) ? null : administrativeProperties.AssignedUserID; var ap = AdministrativeProperties_DTO.Get(administrativeProperties.OnlineExemptionID); //Creaet New if (ap == null) { using (var context = new HomesteadViewerContext()) { var newAp = new AdministrativeProperties_DTO() { OnlineExemptionID = administrativeProperties.OnlineExemptionID, Comment = administrativeProperties.Comment, FollowUpDate = administrativeProperties.FollowUpDate, Status = administrativeProperties.Status, QuickrefID = administrativeProperties.QuickrefID, AssignedUserID = administrativeProperties.AssignedUserID }; if (newAp.Status != ExemptionStatus.NotWorked) newAp.DateStatusChanged = DateTime.Now; if (administrativeProperties.AssignedUserID != null) newAp.DateAssigned = DateTime.Now; context.AdministrativeProperties_Collection.Add(newAp); context.SaveChanges(); return LogChange(administrativeProperties.OnlineExemptionID); } } //Update using (var context = new HomesteadViewerContext()) { ap.Comment = administrativeProperties.Comment; ap.FollowUpDate = administrativeProperties.FollowUpDate; ap.QuickrefID = administrativeProperties.QuickrefID; if (ap.Status != administrativeProperties.Status) ap.DateStatusChanged = DateTime.Now; ap.Status = administrativeProperties.Status; if (ap.AssignedUserID != administrativeProperties.AssignedUserID) ap.DateAssigned = DateTime.Now; ap.AssignedUserID = administrativeProperties.AssignedUserID; context.AdministrativeProperties_Collection.Attach(ap); context.Entry(ap).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); return LogChange(administrativeProperties.OnlineExemptionID); } } catch (Exception ex) { throw ex; } }
public static List<MasterExemption_DTO> GetMasterExemption_For(AdministrativeProperties_DTO administrativProperties) { try { using (var context = new MasterHSContext()) { return context.MasterExemptions.Where(qe=>qe.OnlineExemptionID == administrativProperties.OnlineExemptionID).ToList(); } } catch (Exception ex) { throw ex; } }