Exemple #1
0
 public async Task <RepositoryResponse <BEModuleViewModel> > Post([FromBody] BEModuleViewModel model)
 {
     if (model != null)
     {
         return(await model.SaveModelAsync(true).ConfigureAwait(false));
     }
     return(new RepositoryResponse <BEModuleViewModel>());
 }
        public async Task <RepositoryResponse <BEModuleViewModel> > Post([FromBody] BEModuleViewModel model)
        {
            if (model != null)
            {
                //model.CreatedBy = User.Identity.Name;
                var result = await model.SaveModelAsync(true).ConfigureAwait(false);

                return(result);
            }
            return(new RepositoryResponse <BEModuleViewModel>());
        }
Exemple #3
0
        public async Task <IActionResult> Create(BEModuleViewModel Module)
        {
            if (ModelState.IsValid)
            {
                var result = await Module.SaveModelAsync(true).ConfigureAwait(false);

                if (result.IsSucceed)
                {
                    return(RedirectToAction("Details", new { id = Module.Id }));
                }
                else
                {
                    throw new Exception(result.Exception.StackTrace);
                }
            }
            return(View(Module));
        }
Exemple #4
0
        public async Task <IActionResult> Create(BEModuleViewModel Module)
        {
            if (ModelState.IsValid)
            {
                var result = await Module.SaveModelAsync();

                if (result.IsSucceed)
                {
                    return(RedirectToAction("Index"));
                }
                else
                {
                    throw new Exception(result.Exception.StackTrace);
                }
            }
            return(View(Module));
        }
Exemple #5
0
        public async Task <IActionResult> Edit(int id, BEModuleViewModel Module)
        {
            if (id != Module.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    var result = await Module.SaveModelAsync(true).ConfigureAwait(false);

                    if (result.IsSucceed)
                    {
                        return(RedirectToAction("Details", new { id = Module.Id }));
                    }
                    else
                    {
                        ModelState.AddModelError(string.Empty, result.Exception.Message);
                        return(View(Module));
                    }
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BEModuleViewModel.Repository.CheckIsExists(m => m.Id == Module.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                //return RedirectToAction("Index");
            }
            ViewData["Action"]     = "Edit";
            ViewData["Controller"] = "Pages";
            return(View(Module));
        }