예제 #1
0
        public async Task <ActionResult> SelectRemoveCource(int?id)
        {
            if (id == null)
            {
                return(Content(null));
            }
            string               resultmsg = id.Value.ToString();
            Election             ele       = _ElectionService.GetById(id.Value);
            PeresentedCourses    pc        = _PeresentedCoursesService.GetById(ele.PeresentedCource.Id);
            ElectionRemoveStatus status    = _ElectionService.Remove(ele.Id);

            switch (status)
            {
            case ElectionRemoveStatus.Success:
            {
                _ElectionService.Delete(id.Value);

                _PeresentedCoursesService.Increase_Capacity_Remained(pc.Id);
                await _unitOfWork.SaveAllChangesAsync(false);

                resultmsg = "Success Remove";
            }
            break;

            case ElectionRemoveStatus.CannotRemoveScored:
                resultmsg = "Cannot Remove Beacuse This Cource has Scored";
                break;
            }

            await _unitOfWork.SaveChangesAsync();

            CacheManager.InvalidateChildActionsCache();
            return(Json(new { msg = resultmsg }, JsonRequestBehavior.AllowGet));
        }