/// <summary> /// Updates an existing template /// </summary> /// <param name="model"></param> /// <returns></returns> public IHttpActionResult Put([FromBody] SmsTemplateModel model) { Validate(model); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (string.IsNullOrWhiteSpace(model.RowVersion)) { return(BadRequest("This method is not allowed to Create an entity. Please use the POST verb")); } try { _templateServices.Update(AutoMapper.Mapper.Map <EFModel.Template>(model)); _UoW.Commit(); return(Ok()); } catch (Exception ex) { return(InternalServerError(ex)); } }
/// <summary> /// Creates a new template /// </summary> /// <param name="model"></param> /// <returns></returns> public IHttpActionResult Post([FromBody] SmsTemplateModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (!string.IsNullOrWhiteSpace(model.RowVersion)) { return(BadRequest("This method is not allowed to update an entity. Please use the PUT verb")); } try { _templateServices.CreateTemplate(AutoMapper.Mapper.Map <EFModel.Template>(model)); _UoW.Commit(); return(StatusCode(HttpStatusCode.Created)); //TODO:Return the new value //return Created<SmsTemplateModel>(Request.RequestUri + newCust.ID.ToString(), newCust); } catch (Exception ex) { return(InternalServerError(ex)); } }
public ActionResult SendTestSms(SmsTemplateModel model) { SmsTemplate smsTemplate = smsBusinessLogic.SmsTemplate_Get(); smsTemplate.Phone = model.Phone; model.GetSmsTemplate(smsTemplate); smsTemplate = model.SetSmsTemplate(); SMSMessage smsMessage = new SMSMessage() { Id = 1,//в тестовой отправке смс ID не критично SenderId = smsTemplate.SenderId, Phone = smsTemplate.Phone, Message = smsTemplate.Message }; if (!string.IsNullOrEmpty(smsMessage.Phone)) { model.Result = SmsSender.SmsSender.SendOneSms(smsMessage); if (string.IsNullOrEmpty(model.Result)) { model.Result = "Смс успешно отправлено."; } } else { model.Result = "Введите номер телефона!"; } return(View("Index", model)); }
public ActionResult Index() { SmsTemplate sms = smsBusinessLogic.SmsTemplate_Get(); SmsTemplateModel model = new SmsTemplateModel(); model.GetSmsTemplate(sms); return(View(model)); }
public ActionResult Save(SmsTemplateModel _data, long ID) { _data.CreatedOn = DateTime.Now; var data = repo.Save <SmsTemplateModel>(_data, ID); if (data != null) { return(RedirectToAction("Index", "SmsTemplates")); } else { ModelState.AddModelError("", "Somehting went wront. Please try again"); return(View()); } }