public void SetModel(AddTemplateViewModel viewModel) { DisableAll(); titleTextBox.Text = viewModel.Title; descriptionTextBox.Text = viewModel.Title; }
public ActionResult Add(AddTemplateViewModel addTemplateViewModel) { addTemplateViewModel.PageId = "Template"; if (addTemplateViewModel.fileUpload != null && addTemplateViewModel.fileUpload.ContentLength > 0) { if (addTemplateViewModel.fileUpload.FileName.Split('.')[1] != "docx") { ModelState.AddModelError("error", "فرمت فایل قالب باید ورد باشد."); return(View(addTemplateViewModel)); } //addTemplateViewModel.template.File = new ArchiveFile(); //Get Content of image MemoryStream target = new MemoryStream(); addTemplateViewModel.fileUpload.InputStream.CopyTo(target); addTemplateViewModel.template.File.Content = target.ToArray(); //addTemplateViewModel.template.File.Name = addTemplateViewModel.fileUpload.FileName; addTemplateViewModel.template.File.ContentType = addTemplateViewModel.fileUpload.ContentType; } else { ModelState.AddModelError("error", "فایل قالب وارد نشده است."); return(View(addTemplateViewModel)); } TemplateManager templateManager = new TemplateManager(); templateManager.Add(addTemplateViewModel.template); templateManager.saveChanges(); return(RedirectToAction("Index")); }
public ActionResult Add() { AddTemplateViewModel addTemplateViewModel = new AddTemplateViewModel { PageId = "Template" }; return(View(addTemplateViewModel)); }
public async Task Create(AddTemplateViewModel model) { var template = new Template(); template.Body = model.Body; template.Subject = model.Subject; await _repo.Create(template); }
public async Task <JsonResult> AddContractTemplate([Required] AddTemplateViewModel model) { if (!ModelState.IsValid) { return(JsonModelStateErrors()); } return(await JsonAsync(_service.AddContractTemplateAsync(model))); }
private void listView1_SelectedIndexChanged(object sender, EventArgs e) { if (listView1.SelectedItems.Count == 1) { var item = listView1.SelectedItems[0]; var model = new AddTemplateViewModel { Title = item.SubItems[0].Text, Description = item.SubItems[1].Text, }; ShowNewForm(_addNewTemplateController.GenerateView(model)); } }
/// <summary> /// Add new contract template /// </summary> /// <param name="model"></param> /// <returns></returns> public virtual async Task <ResultModel <Guid> > AddContractTemplateAsync([Required] AddTemplateViewModel model) { if (model == null) { return(new InvalidParametersResultModel <Guid>()); } var template = _mapper.Map <ContractTemplate>(model); await _context.ContractTemplates.AddAsync(template); var dbResult = await _context.PushAsync(); await _notify.SendNotificationAsync(new Notification { Content = $"Add new document template {template?.Name}", Subject = "Info", NotificationTypeId = NotificationType.Info }); return(!dbResult.IsSuccess ? dbResult.Map <Guid>() : new SuccessResultModel <Guid>(template.Id)); }
public AddTemplatePage() { InitializeComponent(); _vm = new AddTemplateViewModel(); BindingContext = _vm; }
public async Task Create([FromBody] AddTemplateViewModel model) { await _service.Create(model); }