public JsonResult UploadWork(int member_id, int category_id) { var conferencion = _unitOfWork.ConferenceRepository.FirstOrDefault(conf => conf.IsActive); if (conferencion == null) { Response.StatusCode = (int)HttpStatusCode.InternalServerError; return(Json(Constants.NO_ACTIVE_CONFERENCE_MESSAGE)); } var category = _unitOfWork.ConferenceCategoryRepository.FirstOrDefault(categ => categ.Id == category_id); if (category == null) { Response.StatusCode = (int)HttpStatusCode.InternalServerError; return(Json("No category with id " + category_id)); } if (!category.IsActive) { Response.StatusCode = (int)HttpStatusCode.InternalServerError; return(Json("Category is no active")); } if (category.ConferenceId != conferencion.Id) { Response.StatusCode = (int)HttpStatusCode.InternalServerError; return(Json("Selected category is not active")); } if (!conferencion.IsAvailableForRegistration) { Response.StatusCode = (int)HttpStatusCode.InternalServerError; return(Json("Registration on conferention is closed")); } if (!conferencion.IsActive) { Response.StatusCode = (int)HttpStatusCode.InternalServerError; return(Json("Conferention is closed")); } var model = new UploadWorkViewModel { CategoryId = category_id, MemberId = member_id, UploadedWorks = _unitOfWork.MembersWorksRepository.Get( work => work.CategoryId == category_id && work.MemberId == member_id) }; return(Json(Common.RenderViewToString(this, "_UploadWork", model), JsonRequestBehavior.AllowGet)); }
public async Task <IActionResult> UploadWork(UploadWorkViewModel workViewModel) { var userId = User.FindFirstValue(ClaimTypes.NameIdentifier); var specialist = await _specialistService.FindAsync(userId); if (ModelState.IsValid) { var result = await _specialistService.AddWork(specialist.Id, workViewModel.Image, workViewModel.Description); if (result != null) { TempData["Status"] = "Work sent successfully"; return(RedirectToAction("Works")); } TempData["Status"] = "Work did not upload"; } return(View(workViewModel)); }