public ConsumerFullViewModel(Consumer model) { CustomMapper.MapEntity(model, this); if (model.Advocate != null) { this.AdvocateName = model.Advocate.LastName + ", " + model.Advocate.FirstName; } if (model.AdvocatePaper != null) { this.AdvocatePaperName = model.AdvocatePaper.LastName + ", " + model.AdvocatePaper.FirstName; } if (this.Status.HasValue) { this.StatusName = model.List.ListDescription; } this.DateOfBirth = (model.DateOfBirth != null ? DateTime.SpecifyKind(model.DateOfBirth.Value, DateTimeKind.Unspecified) : model.DateOfBirth); this.HasServiceCoordinator = model.HasServiceCoordinator.HasValue ? model.HasServiceCoordinator.Value : false; this.CH = new Contact(model.CHCoordinatorId, model.CHCoordinator); this.DH = new Contact(model.DHCoordinatorId, model.DHCoordinator); this.MSC = new Contact(model.MSCId, model.MSCoordinator); this.ServiceCoordinator = new Contact(model.ServiceCoordinatorId, model.ServiceCoordinatorContact); this.ServiceCoordinators = CustomMapper.MapList <ConsumerServiceCoordinatorViewModel, ConsumerServiceCoordinator>(model.ConsumerServiceCoordinators.ToList()); this.Addresses = CustomMapper.MapList <ConsumerAddressModelView, ConsumerAddress>(model.ConsumerAddresses.ToList()); this.MedicaidNumbers = CustomMapper.MapList <ConsumerMedicaidNumberViewModel, ConsumerMedicaidNumber>(model.ConsumerMedicaidNumbers.ToList()); }
static public List <TDestionation> GetClientList <TSource, TDestionation>(List <TSource> models) where TDestionation : class, new() { List <TDestionation> result = new List <TDestionation>(); result = models.Select(x => CustomMapper.MapEntity <TSource, TDestionation>(x)).ToList(); return(result); }
public async Task <ActionResult> Save(ConsumerServiceViewModel model) { if (User == null) { return(null); } ConsumerServicesManagement manage = new ConsumerServicesManagement(_context); if (model.ConsumerServiceId == null) { model.CreatedByUserId = CurrentUser?.UserId; } else { model.EditedByUserId = CurrentUser?.UserId; } var dbData = await manage.Save(model.GetModel()); ConsumerServiceViewModel savedData = CustomMapper.MapEntity <ConsumerServiceViewModel>(dbData); if (!string.IsNullOrEmpty(model.FileData)) { var savedFileInfo = manage.SaveConsumerEmployeeFile(CurrentUser, dbData.ConsumerServiceId, model.FileData, model.FileName, model.FileId); model.FileId = savedFileInfo.fileId; model.FileName = savedFileInfo.fileName; } var returnObj = new { status = "ok", id = savedData.ConsumerServiceId, savedData.AddedByView, savedData.EditedByView, fileId = model.FileId, fileName = model.FileName }; return(Json(returnObj, JsonRequestBehavior.AllowGet)); }
public async Task <ConsumerService> Save(ConsumerService newData) { ConsumerService dbModel = null; var isNew = newData.ConsumerServiceId == 0; if (isNew) { dbModel = _context.ConsumerServices.Add(newData); } else { dbModel = await _context.ConsumerServices.SingleOrDefaultAsync(x => x.ConsumerServiceId == newData.ConsumerServiceId); if (dbModel != null) { CustomMapper.MapEntity(newData, dbModel); } } await _context.SaveChangesAsync(); if (isNew) { _context.Entry(dbModel).Reference(c => c.SystemUser).Load();; } return(CustomMapper.MapEntity(dbModel, newData));; }
public Consumer GetModel() { Consumer model = new Consumer(); CustomMapper.MapEntity(this, model); model.MI = this.MiddleName; model.ConsumerId = this.ConsumerId ?? 0; if (this.ServiceCoordinator != null) { model.ServiceCoordinatorId = this.ServiceCoordinator.Id; } if (this.DH != null) { model.DHCoordinatorId = this.DH.Id; } if (this.CH != null) { model.CHCoordinatorId = this.CH.Id; } if (this.MSC != null) { model.MSCId = this.MSC.Id; } return(model); }
public ConsumerHabPlanValuedOutcomeViewModel(ConsumerHabPlanValuedOutcome model) { CustomMapper.MapEntity(model, this); if (model.ConsumerHabPlanVOServeActions != null) { this.ServeActions = ConsumerHabPlanVOServeActionViewModel.GetList(model.ConsumerHabPlanVOServeActions.ToList()); } else { this.ServeActions = new List <ConsumerHabPlanVOServeActionViewModel>(); } }
public static FileMetaDataModel SaveFileMetaData(RayimContext context, FileMetaDataModel model) { bool isNew = model.Id == 0; FileMetaData dbFileData = context.FileMetaDatas.FirstOrDefault(x => x.Id == model.Id) ?? new FileMetaData(); CustomMapper.MapEntity(model, dbFileData); if (isNew) { context.FileMetaDatas.Add(dbFileData); } context.SaveChanges(); return(CustomMapper.MapEntity <FileMetaDataModel>(dbFileData)); }
public static List <AuditModel> GetAudits(RayimContext context, DateTime?auditDate = null) { var dbAudits = context.Audits.Where(x => auditDate == null || x.AuditDate <= auditDate).ToList(); var modelAudits = dbAudits.Select(x => { var result = CustomMapper.MapEntity <AuditModel>(x); result.Consumers = CustomMapper.MapList <ConsumerModel, Database.Consumer>(x.Consumers.ToList()); return(result); }).ToList(); return(modelAudits); }
public async Task <ConsumerServiceModel> GetService(int serviceId, bool withRelatedData = false) { var service = await _context.ConsumerServices.FirstOrDefaultAsync(x => x.ConsumerServiceId == serviceId); ConsumerServiceModel returnData = CustomMapper.MapEntity <ConsumerServiceModel>(service); if (withRelatedData && service != null && service.ConsumerId != null) { ConsumerEmployeeManagement manageEmployees = new ConsumerEmployeeManagement(_context); var employees = await manageEmployees.GetEmployees(service.ConsumerId.Value, service.ServiceId); returnData.ConsumerEmployeeList = CustomMapper.MapList <ConsumerEmployeeModel, ConsumerEmployee>(employees); } return(returnData); }
public ActionResult AddOrUpdateConsumerFile() { FileMetaDataModelView inputModel = RequestManager.GetModelFromJsonRequest <FileMetaDataModelView>(HttpContext.Request); if (inputModel == null) { return(null); } inputModel.ParentEntityTypeId = (int)EntityTypes.Consumer; FileDataService.UpdateFileMetaData(inputModel, CurrentUser.UserId); var result = FileDataService.SaveFileDataWithFile(_context, inputModel, inputModel.FileData); var returnData = CustomMapper.MapEntity <FileMetaDataModelView>(result); return(Json(new { status = "ok", model = returnData }, JsonRequestBehavior.AllowGet)); }
public List <ConsumerHabPlanSafeguard> GetSafeguardsModel() { List <ConsumerHabPlanSafeguard> result = new List <ConsumerHabPlanSafeguard>(); if (Safeguards == null) { return(result); } foreach (var item in Safeguards) { ConsumerHabPlanSafeguard model = CustomMapper.MapEntity <ConsumerHabPlanSafeguard>(item); result.Add(model); } return(result); }
public static ConsumerMedicaidNumberModel CreateOrUpdate(RayimContext context, ConsumerMedicaidNumberModel model) { var dbEntity = context.ConsumerMedicaidNumbers.FirstOrDefault(x => x.Id == model.Id); if (dbEntity == null) { var map = CustomMapper.MapEntity <ConsumerMedicaidNumber>(model); dbEntity = context.ConsumerMedicaidNumbers.Add(map); } else { CustomMapper.MapEntity <ConsumerMedicaidNumber>(model, dbEntity); } context.SaveChanges(); return(CustomMapper.MapEntity <ConsumerMedicaidNumberModel>(dbEntity)); }
public ConsumerEmployee GetModel() { ConsumerEmployee model = new ConsumerEmployee(); CustomMapper.MapEntity(this, model); if (this.ConsumerEmployeeId.HasValue) { model.ConsumerEmployeeId = this.ConsumerEmployeeId.Value; } else { model.ConsumerEmployeeId = 0; } return(model); }
public static ConsumerAddressModel CreateOrUpdate(RayimContext context, BaseConsumerAddressModel inputModel) { var isNew = inputModel.Id == 0; var dbEntity = context.ConsumerAddresses.FirstOrDefault(x => x.Id == inputModel.Id); if (dbEntity == null) { dbEntity = context.ConsumerAddresses.Add(CustomMapper.MapEntity <ConsumerAddress>(inputModel)); } else { CustomMapper.MapEntity <ConsumerAddress>(inputModel, dbEntity); } context.SaveChanges(); return(CustomMapper.MapEntity <ConsumerAddressModel>(dbEntity)); }
public ConsumerEmployeeViewModel(ConsumerEmployee model) { CustomMapper.MapEntity(model, this); var employeeFiles = ConsumerEmployeeManagement.GetFilesByConsumerEmployeeId(model.ConsumerEmployeeId).FirstOrDefault(); FileId = employeeFiles?.Id; FileName = employeeFiles?.FileDisplayName; this.ContactName = model.Contact.FirstName + " " + model.Contact.LastName; if (this.ServiceId.HasValue) { this.ServiceName = model.ServicesList.ServiceDescription; } if (model.Contact.AgencyNameId.HasValue) { this.CompanyName = model.Contact.Agency.NameCompany; } }
public ActionResult Save(ConsumerServiceCoordinatorViewModel viewModel) { if (User == null) { return(null); } object result = null; var inputModel = CustomMapper.MapEntity <BaseConsumerServiceCoordinatorModel>(viewModel); if (ConsumerServiceCoordinatorManagement.Validate(_context, inputModel)) { var entity = ConsumerServiceCoordinatorManagement.CreateOrUpdate(_context, inputModel); result = new { status = "ok", model = CustomMapper.MapEntity <ConsumerServiceCoordinatorViewModel>(entity), New = viewModel.Id == 0 }; } else { result = new { status = "error", errorMessage = "not valid date range for MSC" }; } return(Json(result, JsonRequestBehavior.AllowGet)); }
public async Task <ActionResult> SendEmail(int noteId, String email, string emailBody, String contactName) { if (User == null) { return(null); } ConsumerNotesManagement manage = new ConsumerNotesManagement(_context); var note = await manage.GetNote(noteId); var mappedData = CustomMapper.MapEntity <ConsumerNote, CustomerNotesBoundModel>(note); mappedData.InnerEmailBody = emailBody; List <Object> emailInputData = new List <object>() { mappedData }; await EmailService.SendBoundEmail(email, contactName, "Notes Email", "note-email", emailInputData, User?.Identity?.Name); return(Json(new { status = "ok" })); }
public async Task <ActionResult> SendEmail(int serviceId, String email, string emailBody, String contactName) { if (User == null) { return(null); } ConsumerServicesManagement manage = new ConsumerServicesManagement(_context); var service = await manage.GetService(serviceId, true); var mappedData = CustomMapper.MapEntity <ConsumerServiceModel, ApprovedServiceBoundModel>(service); mappedData.ConsumerEmployeeList = CustomMapper.MapList <ConsumerEmployeeModel, ConsumerEmployeeModel>(service.ConsumerEmployeeList); mappedData.InnerEmailBody = emailBody; List <Object> emailInputData = new List <object>() { mappedData }; await EmailService.SendBoundEmail(email, contactName, "Approver Service Email", "apporved-service-email", emailInputData, User?.Identity?.Name); return(Json(new { status = "ok" })); }
public static ConsumerServiceCoordinatorModel CreateOrUpdate(RayimContext context, BaseConsumerServiceCoordinatorModel inputModel) { var isNew = inputModel.Id == 0; var dbEntity = context.ConsumerServiceCoordinators.FirstOrDefault(x => x.Id == inputModel.Id); if (dbEntity == null) { dbEntity = context.ConsumerServiceCoordinators.Add(CustomMapper.MapEntity <ConsumerServiceCoordinator>(inputModel)); } else { CustomMapper.MapEntity <ConsumerServiceCoordinator>(inputModel, dbEntity); } context.SaveChanges(); if (isNew) { context.Entry(dbEntity).Reference(c => c.Contact).Load();; } return(CustomMapper.MapEntity <ConsumerServiceCoordinatorModel>(dbEntity)); }
public List <ConsumerHabPlanValuedOutcome> GetOutcomesModel() { List <ConsumerHabPlanValuedOutcome> result = new List <ConsumerHabPlanValuedOutcome>(); if (ValuedOutcomes == null) { return(result); } var fakeId = -1; foreach (var item in ValuedOutcomes) { item.Id = fakeId; foreach (var action in item.ServeActions) { action.Id = 0; action.ValuedOutcomeId = fakeId; } fakeId--; ConsumerHabPlanValuedOutcome model = CustomMapper.MapEntity <ConsumerHabPlanValuedOutcome>(item); result.Add(model); } return(result); }
public ActionResult Save(ConsumerMedicaidNumberViewModel model) { if (User == null) { return(null); } object result = null; var inputModel = CustomMapper.MapEntity <ConsumerMedicaidNumberModel>(model); var validationErrors = ConsumerMedicaidNumberManagement.Validate(_context, inputModel); if (!validationErrors.Any()) { var entity = ConsumerMedicaidNumberManagement.CreateOrUpdate(_context, inputModel); result = new { status = "ok", model = CustomMapper.MapEntity <ConsumerMedicaidNumberViewModel>(entity), New = model.Id == 0 }; } else { result = validationErrors.Select(error => new { status = "error", errorMessage = error }); } return(Json(result, JsonRequestBehavior.AllowGet)); }
public static FileMetaDataModel GetFileMetadata(RayimContext context, int fileId) { var dbEntity = context.FileMetaDatas.FirstOrDefault(x => x.Id == fileId); return(CustomMapper.MapEntity <FileMetaDataModel>(dbEntity)); }
public static ReportAddressModel GetScheduledAddressByDate(RayimContext context, DateTime actualDate, Int32 consumerId) { var foundRecord = context.ConsumerAddresses.FirstOrDefault(x => x.ConsumerId == consumerId && x.FromDate <= actualDate && (actualDate <= x.ToDate || x.ToDate == null)); return(foundRecord != null?CustomMapper.MapEntity <ReportAddressModel>(foundRecord) : null); }
public ConsumerHabPlanSafeguardViewModel(ConsumerHabPlanSafeguard model) { CustomMapper.MapEntity(model, this); this.Id = model.ConsumerHabPlanSafeguardId; }