Ejemplo n.º 1
0
        public async Task <IActionResult> Edit(Mission mission, IFormFile file)
        {
            if (file != null)
            {
                var path   = Path.Combine(_environment.WebRootPath, "Photo", file.FileName);
                var stream = new FileStream(path, FileMode.Create);
                file.CopyTo(stream);
                mission.Photo = file.FileName;
            }
            mission.UpdateDate = DateTime.Now;
            mission.User       = await _userManager.GetUserAsync(User);

            mission.UpdatedBy = await _userManager.GetUserNameAsync(mission.User);

            _missionService.Update(mission);
            return(RedirectToAction("Index", "mission"));
        }
        public IActionResult Update(int id, [FromBody] MissionViewModel mission)
        {
            if (mission == null || mission.Id != id)
            {
                return(BadRequest());
            }

            var retVal = _missionService.Update(mission);

            if (retVal == 0)
            {
                return(StatusCode(304));                 //Not Modified
            }
            else if (retVal == -1)
            {
                return(StatusCode(412, "DbUpdateConcurrencyException"));  //412 Precondition Failed  - concurrency
            }
            else
            {
                return(Accepted(mission));
            }
        }
Ejemplo n.º 3
0
        public ActionResult EditMission(Mission Mission)
        {
            string message;

            if (ModelState.IsValid)
            {
                message = MissionService.Update(Mission, User.Identity.Name);
                if (String.IsNullOrEmpty(message))
                {
                    TempData["Success"] = Messages.Updated;
                    return(RedirectToAction("Index"));
                }
                else
                {
                    ViewData["Warning"] = message;
                }
            }
            else
            {
                ViewData["Warning"] = Messages.InvalidField;
            }
            return(View());
        }