public void Update(EwiFile entity) { _fileRepository.Update(entity); }
public int Create(EwiFile entity) { _fileRepository.Insert(entity); return(entity.Id); }
public void Delete(EwiFile entity) { entity.IsDeleted = true; _fileRepository.Update(entity); }
public ActionResult UploadFile(int employeeId, int fileType) { foreach (string item in Request.Files) { HttpPostedFileBase file = Request.Files[item] as HttpPostedFileBase; if (file.ContentLength == 0) { continue; } if (file.ContentLength > 0) { try { string fileName = file.FileName; string uploadPath = string.Empty; if (fileType == (int)FileType.EmployeeProfilePhoto) { uploadPath = Server.MapPath("~/Content/ProfilePhotos/"); } else { uploadPath = "MediaFiles/"; } if (!Directory.Exists(uploadPath)) { Directory.CreateDirectory(uploadPath); } string guidFolder = Guid.NewGuid().ToString(); string path = uploadPath + guidFolder; Directory.CreateDirectory(path); path = path + "/" + fileName; file.SaveAs(path); var now = DateTime.Now; EwiFile newFile = new EwiFile() { ParentObjectId = employeeId, FileName = path, FileType = (FileType)fileType, CreatedDate = now, UpdatedDate = now, ContentType = file.ContentType }; _fileService.Create(newFile); } catch (Exception e) { logger.Error(e, e.Message); } } } return(Json("")); }