Пример #1
0
        public ActionResult AddOrUpdate(RequestViewModel requestViewModel)
        {
            try
            {
                var username    = User.FindFirst(ClaimTypes.Name);
                var requestorId = _context.Account.SingleOrDefault(c => c.Username.Equals(username.Value)).Id;

                var result = _request.AddRequest(requestViewModel, requestorId);
                if (result != null)
                {
                    ViewBag.msg = "Done";
                    return(RedirectToAction("Index"));
                }
                else
                {
                    ViewBag.msg = "Failed";
                    return(View("Add", requestViewModel));
                }
            }
            catch
            {
                ViewBag.msg = "Failed";
                return(View("Add", requestViewModel));
            }
        }