/// <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 CreateEdit(Models.SmsTemplate.SmsTemplateViewModel vm) { // Demo using FluentValidation if (!ModelState.IsValid) { return(View(vm)); } //var regExp = "<div class=\"alert alert-dismissible alert-success\" contenteditable=\"false\" style=\"display:inline-block\"><button type=\"button\" class=\"close\" data-dismiss=\"alert\">×</button><span>" + templateField.Name + "</span></div>"; // strip any additional spaces that Js might add in the experssion vm.Text = Regex.Replace(vm.Text, "alert\\s*-\\s*dismissible", "alert-dismissible"); vm.Text = Regex.Replace(vm.Text, "alert\\s*-\\s*success", "alert-success"); vm.Text = Regex.Replace(vm.Text, "data\\s*-\\s*dismiss", "alert-dismiss"); if (vm.Id != 0) { templateServices.Update(AutoMapper.Mapper.Map <EFModel.Template>(vm)); } else { templateServices.CreateTemplate(AutoMapper.Mapper.Map <EFModel.Template>(vm)); } UoW.Commit(); return(RedirectToAction("Index")); }