public ActionResult CreateUpdateTextTemplate([FromBody] SMSText smsText) { try { m_log.Info("Calling textTemplate/save endpoint"); if (m_user.HospitalId == 0) { var ErrorMessage = "Failed to load hospital ID from the User "; m_log.Error(ErrorMessage); throw new NullOrEmptyValueException(ErrorMessage); } if (string.IsNullOrEmpty(smsText.TextTemplateName)) { throw new UserInputValidationException("Text Template name cannot be empty"); } if (smsText.RulesetId == null || smsText.RulesetId == Guid.Empty) { throw new UserInputValidationException("Cannot add empty schedule for a text template"); } smsText.HospitalId = m_user.HospitalId; var textTemplateId = m_textTeplateService.SaveSMSTextTemplate(smsText); return(Ok(textTemplateId)); } catch (Exception e) { m_log.ErrorException("Exception thrown at textTemplate/save endpoint.", e); var ErrorMessage = "Save SMS text template failed!"; m_log.ErrorException(ErrorMessage, e); throw; } }
private TextTemplateDTO MapModelToDataDTO(SMSText textTemplate) { var textTemplateDataDto = new TextTemplateDTO() { IsActive = textTemplate.isActive, DepartmentID = textTemplate.DepartmentId, SectionID = textTemplate.SectionId, WardID = textTemplate.WardId, OPDID = textTemplate.OPDId, LocationID = textTemplate.LocationId, AttachPSSLink = textTemplate.isPSSLinkInclude, IsVideoAppoinment = textTemplate.IsVideoAppoinment, HospitalID = textTemplate.HospitalId, Name = textTemplate.TextTemplateName, ValidTo = textTemplate.ValidTo, ValidFrom = textTemplate.ValidFrom, OfficialLevelOfCare = textTemplate.OfficialLevelOfCare, ContactType = textTemplate.ContactType, TemplateGUID = (textTemplate.TextTemplateId == null || textTemplate.TextTemplateId == Guid.Empty) ? null : textTemplate.TextTemplateId, RuleSetGUID = (textTemplate.RulesetId == null || textTemplate.RulesetId == Guid.Empty) ? null : textTemplate.RulesetId }; if (textTemplate.GroupTemplateId != null && textTemplate.GroupTemplateId != Guid.Empty) { textTemplateDataDto.GroupedTextGUID = textTemplate.GroupTemplateId; } if (!string.IsNullOrEmpty(textTemplate.SMSTextTemplate)) { textTemplateDataDto.SMSText = textTemplate.SMSTextTemplate; } return(textTemplateDataDto); }
private SMSText MapDataDtoToModel(TextTemplateDTO dto) { var smsText = new SMSText { TextTemplateId = dto.TemplateGUID, DepartmentId = dto.DepartmentID, TemplateDepartmentId = dto.TemplateDepartmentID, HospitalId = dto.HospitalID, SectionId = dto.SectionID, WardId = dto.WardID, OPDId = dto.OPDID, LocationId = dto.LocationID, isPSSLinkInclude = dto.AttachPSSLink, IsVideoAppoinment = dto.IsVideoAppoinment, IsGenerateSMS = dto.IsGenerateSMS, isActive = dto.IsActive, TextTemplateName = dto.Name, ValidTo = dto.ValidTo, ValidFrom = dto.ValidFrom, OfficialLevelOfCare = dto.OfficialLevelOfCare, ContactType = dto.ContactType, RulesetId = (dto.RuleSetGUID == null || dto.RuleSetGUID == Guid.Empty) ? null : dto.RuleSetGUID, RuleSetName = dto.RuleSetName, SendSMSBeforeDays = dto.SendSMSBeforeDays, EcludedOrgIds = dto.ExcludedOrgUnits, SMSTextTemplate = dto.SMSText }; if (dto.GroupedTextGUID != null && dto.GroupedTextGUID != Guid.Empty) { smsText.GroupTemplateId = dto.GroupedTextGUID; } return(smsText); }
private SMSText GetSmsTextTemplate(long hospitalid, long?depId, long?opd, long?locId, long?secId, long?wardId, bool isActive, Guid?ruleId, Guid?textTemplateId, Guid?groupTempId, Guid?ruleSetId, bool isVideo = false, string smsText = "Test text", string textTemplateName = "template name") { var smsTextModel = new SMSText { isActive = isActive, SMSTextTemplate = smsText, TextTemplateName = textTemplateName, HospitalId = hospitalid, TextTemplateId = textTemplateId, GroupTemplateId = groupTempId, RulesetId = ruleId, IsVideoAppoinment = isVideo }; if (depId != null) { smsTextModel.DepartmentId = (long)depId; } if (locId != null) { smsTextModel.LocationId = (long)locId; } if (secId != null) { smsTextModel.SectionId = (long)secId; } if (wardId != null) { smsTextModel.WardId = (long)wardId; } if (opd != null) { smsTextModel.OPDId = (long)opd; } return(smsTextModel); }
private void Update() { TSymbols.Text = SMSText.Count().ToString(); }
public Guid SaveSMSTextTemplate(SMSText textTemplate) { return(m_TextTemplateDataService.SaveTextTemplate(MapModelToDataDTO(textTemplate))); }