public ActionResult ForgottenPassword(string email) { using (_securityService.BeginSystemContext()) { var q = new EntityQuery2("User"); q.WhereIs("Email", email); q.WhereIs("IsActive", true); Entity user = _entityService.Query(q).SingleOrDefault(); if (user == null) { ModelState.AddModelError("email", string.Format("В системата няма активен потребител с имейл \"{0}\". За помощ: тел. 02 8110296.", email)); return(View()); } else { var recoveryCode = Guid.NewGuid().ToString(); var update = new EntityUpdate(user.Name, user.Id); update.Set("RecoveryCode", recoveryCode); var result = _entityService.Update(update); if (result.Success) { return(View("ForgottenPassword_Success", (object)email)); } else { ModelState.AddModelError("email", "Възникна грешка при стартиране на процеса по възстановяване на забравена парола. За помощ: тел. 02 8110296."); return(View()); } } } }
public ActionResult Upload() { var response = new FileUploadResponse(); foreach (string filename in Request.Files) { var file = Request.Files[filename]; var stat = _fileService.CanUpload(file.FileName, file.ContentLength); if (stat == CanUploadStatus.FileTypeNotAllowed) { throw new Exception("Files of this type are not allowed."); } else if (stat == CanUploadStatus.DiskUsageLimitExceeded) { throw new Exception("Disk usage limit exceeded."); } Guid id = _fileService.StoreFileContent(file.InputStream); var f = new File() { FileName = System.IO.Path.GetFileNameWithoutExtension(file.FileName), ContentType = file.ContentType, ContentPath = id.ToString(), Extension = System.IO.Path.GetExtension(file.FileName), Size = file.ContentLength }; EntityUpdate create = new EntityUpdate(f); var result = _entityService.Update(create); if (result.Success) { response.files.Add(new FileUploadResponse.File() { id = create.Id.Value, name = file.FileName, size = file.ContentLength, url = Url.Action("Download") + "?id=" + create.Id.Value }); } } //System.Threading.Thread.Sleep(500); return(Json(response)); }
public EntityOperationResult Update(EntityUpdateRequest updateRequest) { return(_entityService.Update(updateRequest.ToEntityUpdate())); }