public virtual IActionResult List() { //prepare model TemplatesModel model = _templateModelFactory.PrepareTemplatesModel(new TemplatesModel()); return(View(model)); }
public bool UpdateTemplate(TemplatesModel template) { try { using (var conn = CreateConnection()) { conn.Open(); if (conn.ExecuteScalar <bool>("SELECT COUNT(1) FROM public.\"Templates\" WHERE \"Id\" = @Id", new { template.Id })) { string sql = "UPDATE public.\"Templates\" SET \"AccountNumberCurrent\" = @AccountNumberCurrent, \"AccountNumberReceiver\" = @AccountNumberReceiver, \"PaymentName\" = @PaymentName, \"PaymentPurpose\" = @PaymentPurpose, \"PaymentValue\" = @PaymentValue, \"ReceiverEmail\" = @ReceiverEmail, \"ReceiverName\" = @ReceiverName WHERE \"Id\" = @Id"; conn.Execute(sql, new { template.AccountNumberCurrent, template.AccountNumberReceiver, template.Id, template.PaymentName, template.PaymentPurpose, template.PaymentValue, template.ReceiverEmail, template.ReceiverName }); return(true); } } } catch (Exception e) { Debug.WriteLine(e.Message); } return(false); }
public TemplatesModel CreateTemplate(TemplatesModel template) { try { using (var conn = CreateConnection()) { string sql = "INSERT INTO public.\"Templates\" VALUES (@Id ,@AccountNumberCurrent, @AccountNumberReceiver, @PaymentName, @ReceiverName, @ReceiverEmail, @PaymentPurpose, @PaymentValue);"; conn.Execute(sql, new { Id = Guid.NewGuid(), template.AccountNumberCurrent, template.AccountNumberReceiver, template.PaymentName, template.PaymentPurpose, template.PaymentValue, template.ReceiverEmail, template.ReceiverName }); return(conn.QueryFirstOrDefault <TemplatesModel>("SELECT * FROM public.\"Templates\" WHERE \"AccountNumberCurrent\" = @AccountNumberCurrent;", new { template.AccountNumberCurrent })); } } catch (Exception e) { Debug.WriteLine(e.Message); } return(null); }
/// <summary> /// Prepare templates model /// </summary> /// <param name="model">Templates model</param> /// <returns>Templates model</returns> public virtual TemplatesModel PrepareTemplatesModel(TemplatesModel model) { if (model == null) { throw new ArgumentNullException(nameof(model)); } return(model); }
/// <summary> /// Prepare templates model /// </summary> /// <param name="model">Templates model</param> /// <returns>Templates model</returns> public virtual TemplatesModel PrepareTemplatesModel(TemplatesModel model) { if (model == null) { throw new ArgumentNullException(nameof(model)); } //prepare nested search models PrepareCategoryTemplateSearchModel(model.TemplatesCategory); PrepareTopicTemplateSearchModel(model.TemplatesTopic); return(model); }
public IActionResult UpdateTemplate(TemplatesModel templatesModel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (_service.UpdateTemplate(templatesModel)) { return(Ok()); } return(BadRequest()); }
/// <summary> /// Prepare templates model /// </summary> /// <param name="model">Templates model</param> /// <returns>Templates model</returns> public virtual async Task <TemplatesModel> PrepareTemplatesModelAsync(TemplatesModel model) { if (model == null) { throw new ArgumentNullException(nameof(model)); } //prepare nested search models await PrepareCategoryTemplateSearchModelAsync(model.TemplatesCategory); await PrepareManufacturerTemplateSearchModelAsync(model.TemplatesManufacturer); await PrepareProductTemplateSearchModelAsync(model.TemplatesProduct); await PrepareTopicTemplateSearchModelAsync(model.TemplatesTopic); return(model); }
public IActionResult CreateTemplate(TemplatesModel templatesModel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var template = _service.CreateTemplate(templatesModel); if (template == null) { return(BadRequest()); } return(Ok(template)); }
public int UpdateObject(TemplatesModel obj) { throw new NotImplementedException(); }
public int AddObject(TemplatesModel obj) { return(db.Insert(obj) == true ? 1 : 0); }
public IActionResult PostTemplatesModel([FromBody] TemplatesModel templatesModel) { return(_transactionsRequestHundler.CreateTemplate(templatesModel)); }
public IActionResult PutTemplatesModel([FromRoute] Guid id, [FromBody] TemplatesModel templatesModel) { return(_transactionsRequestHundler.UpdateTemplate(templatesModel)); }