コード例 #1
0
        public async Task <ActionResult> DeleteSpeciality(int id)
        {
            string currentUserId = System.Web.HttpContext.Current.User.Identity.GetUserId();

            if (currentUserId == null)
            {
                return(new HttpUnauthorizedResult());
            }
            SpecialityDTO specialityDTO = await SpecialityService.GetAsync(id);

            ViewBag.SubjectName = specialityDTO.Subject.SubjectName;
            ViewBag.ParentId    = specialityDTO.SubjectId;
            ViewBag.Action      = "SubjectSpecialities";
            if (specialityDTO != null)
            {
                OperationDetails operationDetails = await SpecialityService.DeleteAsync(id, currentUserId);

                if (operationDetails.Succedeed)
                {
                    return(PartialView("Report", operationDetails));
                }
                else
                {
                    ModelState.AddModelError(operationDetails.Property, operationDetails.Message);
                    return(PartialView("Report", operationDetails));
                }
            }
            ViewBag.Message = "Non valid";
            return(PartialView("~/Views/Admin/Speciality/DeleteSpeciality.cshtml", specialityDTO));
        }