Exemplo n.º 1
0
 public ActionResult AddSection(AddSectionViewModel model, int id)
 {
     try
     {
         ViewBag.ClassId = id;
         if (!ModelState.IsValid)
         {
             return(View());
         }
         HttpCookie conString = Request.Cookies.Get("rwxgqlb");
         try
         {
             Section s = new Section(model.Name.ToUpper(), id, Cryptography.Decrypt(conString.Value));
         }
         catch (Exception ex)
         {
             ModelState.AddModelError(string.Empty, ex.Message);
             return(View());
         }
         return(RedirectToAction("ViewClassDetails", new { id = id, s = true }));
     }
     catch (Exception ex)
     {
         return(Content(ex.Message));
     }
 }
Exemplo n.º 2
0
 public async Task <JsonResult> AddSectionToContractTemplate([Required] AddSectionViewModel model)
 {
     if (!ModelState.IsValid)
     {
         return(JsonModelStateErrors());
     }
     return(await JsonAsync(_service.AddSectionToContractTemplateAsync(model)));
 }
Exemplo n.º 3
0
 public AddSectionView(AddSectionViewModel viewModel)
 {
     try
     {
         this.DataContext = this.viewModel = viewModel;
         InitializeComponent();
     }
     catch (Exception ex)
     {
         throw;
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// Add section to contract template
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public virtual async Task <ResultModel <Guid> > AddSectionToContractTemplateAsync([Required] AddSectionViewModel model)
        {
            if (model == null)
            {
                return(new InvalidParametersResultModel <Guid>());
            }
            var section = _mapper.Map <ContractSection>(model);

            section.Order = await GetContractSectionCountAsync(model.ContractTemplateId);

            await _context.ContractSections.AddAsync(section);

            var dbResult = await _context.PushAsync();

            return(dbResult.IsSuccess ? new SuccessResultModel <Guid>(section.Id) : dbResult.Map <Guid>());
        }