public ActionResult LogoPic(int x, int y, int w, int h, string picToUpload, string company) { NullChecker.NullCheck(new object[] { company }); var currentUser = WebSecurity.CurrentUserId; var companyToEdit = unitOfWork.NotExpiredCompanyRepository .GetByID(EncryptionHelper.Unprotect(company)); if (companyToEdit.Admins.Any(a => AuthorizationHelper.isRelevant(a.UserId))) { UploadHelper.CropImage(x, y, w, h, picToUpload); UploadHelper.moveFile(picToUpload, "Company"); if (companyToEdit.logo != null) { UploadHelper.deleteFile(companyToEdit.logo, "Company"); } companyToEdit.logo = picToUpload; unitOfWork.CompanyRepository.Update(companyToEdit); unitOfWork.Save(); return(Json(new { Success = true })); } throw new JsonCustomException(ControllerError.ajaxError); }
public ActionResult ProfilePic(string UId, int x, int y, int w, int h, string picToUpload) { NullChecker.NullCheck(new object[] { UId }); var uid = EncryptionHelper.Unprotect(UId); if (!AuthorizationHelper.isRelevant((int)uid)) { throw new JsonCustomException(ControllerError.ajaxError); } UploadHelper.CropImage(x, y, w, h, picToUpload); UploadHelper.moveFile(picToUpload, "Profile"); var user = unitOfWork.ActiveUserRepository.GetByID(uid); if (user.image != null) { UploadHelper.deleteFile(user.image, "Profile"); } user.image = picToUpload; unitOfWork.ActiveUserRepository.Update(user); unitOfWork.Save(); return(Json(new { Success = true })); }