public ActionResult Execute(UI.Action action) { if (!action.Props.ContainsKey("FileId")) { throw new CustomValidationException("There is not Prop FileId"); } var fileId = Convert.ToInt32(action.Props["FileId"]); var fileService = new DAL.Services.DbFileService(); var file = fileService.GetFile(fileId); return(new ActionResult() { Success = true, ActionType = action.ActionType, Data = new Incoming.File() { Name = file.Name, ContentType = file.ContentType, ContentData = file.ContentData } }); }
public ActionResult Execute(UI.Action action) { if (!action.Props.ContainsKey("FileId")) { throw new CustomValidationException("There is not Prop FileId"); } int fileId = Convert.ToInt32(action.Props["FileId"]); DAL.Services.DbFileService fileService = new DAL.Services.DbFileService(); DAL.Models.File file = fileService.GetFile(fileId); file.Deleted = true; file.DeleteDate = DateTime.Now; file.DeletedBy = CurrentUser.Login; fileService.UpdateFile(file); return(new ActionResult() { Success = true, ActionType = action.ActionType }); }
public ActionResult Execute(UI.Action action) { if (!action.Props.ContainsKey("FieldId")) { throw new CustomValidationException("There is no FieldId in Action.Props"); } int fieldId = Convert.ToInt32(action.Props["FieldId"]); if (fieldId <= 0) { throw new CustomValidationException("fieldId <= 0"); } int docId = action.DocId.Value; IEnumerable <DAL.Models.File> files = (action.Value as List <Incoming.File>).Select(f => new DAL.Models.File() { Name = f.Name, ContentType = f.ContentType, ContentData = f.ContentData, Comment = f.Comment, CreateDate = DateTime.Now, CreatedBy = CurrentUser.Login }); DAL.Services.DbFileService fileService = new DAL.Services.DbFileService(); return(new ActionResult() { Success = true, ActionType = action.ActionType, Data = fileService.AddFiles(fieldId, docId, files).Select(f => new Incoming.File() { Id = f.Id, Name = f.Name, Comment = f.Comment }) }); }