public IHttpActionResult AutoUpdate(int id, object dtoItem) { // authentication BLL.Framework fwBll = new BLL.Framework(); if (id > 0 && !fwBll.CanPerformAction(ControllerContext.GetAuthUserId(), moduleCode, Library.DTO.ModuleAction.CanUpdate)) { // edit case return(InternalServerError(new Exception(Properties.Resources.NOT_AUTHORIZED))); } else if (id == 0 && !fwBll.CanPerformAction(ControllerContext.GetAuthUserId(), moduleCode, Library.DTO.ModuleAction.CanCreate)) { // create new case return(InternalServerError(new Exception(Properties.Resources.NOT_AUTHORIZED))); } executor.identifier = Helper.AuthHelper.GetCurrentUserFolder(ControllerContext); Library.DTO.Notification notification; Hashtable dataItems = new Hashtable(); dataItems["data"] = dtoItem; dataItems["LPRid"] = id; executor.CustomFunction(ControllerContext.GetAuthUserId(), "autoupdate", dataItems, out notification); return(Ok(new Library.DTO.ReturnData <object>() { Data = dtoItem, Message = notification })); }
public IHttpActionResult Browse() { // authentication BLL.Framework bll = new BLL.Framework(); Library.DTO.Notification notification = new Library.DTO.Notification() { Type = Library.DTO.NotificationType.Success }; int totalRows = 0; string userFolder = AuthHelper.GetCurrentUserFolder(ControllerContext); List <Models.FileViewModel> result = new List <Models.FileViewModel>(); try { foreach (string fileName in Directory.GetFiles(userFolder)) { FileInfo info = new FileInfo(fileName); // delete old file < 1 day if (DateTime.Compare(info.CreationTime.AddDays(1), DateTime.Now) < 0) { try { File.Delete(info.FullName); } catch { } } else { result.Add(new Models.FileViewModel() { FileName = info.Name, FileExtension = info.Extension, FriendlyName = info.Name, URL = System.Configuration.ConfigurationManager.AppSettings["ServiceUrl"] + System.Configuration.ConfigurationManager.AppSettings["TempUrl"] + Helper.AuthHelper.GetAuthUserId(ControllerContext).ToString() + "/" + info.Name }); } } } catch (Exception ex) { notification.Type = Library.DTO.NotificationType.Error; notification.Message = ex.Message; } return(Ok(new Library.DTO.ReturnData <IEnumerable <Models.FileViewModel> >() { Data = result, Message = notification, TotalRows = totalRows })); }
public IHttpActionResult Update(int id, object dtoItem) { // authentication BLL.Framework fwBll = new BLL.Framework(); if (id > 0 && !fwBll.CanPerformAction(ControllerContext.GetAuthUserId(), moduleCode, Library.DTO.ModuleAction.CanUpdate)) { // edit case return(InternalServerError(new Exception(Properties.Resources.NOT_AUTHORIZED))); } else if (id == 0 && !fwBll.CanPerformAction(ControllerContext.GetAuthUserId(), moduleCode, Library.DTO.ModuleAction.CanCreate)) { // create new case return(InternalServerError(new Exception(Properties.Resources.NOT_AUTHORIZED))); } //executor.identifier = Helper.AuthHelper.GetCurrentUserFolder(ControllerContext); executor.UpdateData(ControllerContext.GetAuthUserId(), id, ref dtoItem, out Library.DTO.Notification notification); return(Ok(new Library.DTO.ReturnData <object>() { Data = dtoItem, Message = notification })); }
public IHttpActionResult Clear() { // authentication BLL.Framework bll = new BLL.Framework(); Library.DTO.Notification notification = new Library.DTO.Notification() { Type = Library.DTO.NotificationType.Success }; int totalRows = 0; string userFolder = AuthHelper.GetCurrentUserFolder(ControllerContext); List <Models.FileViewModel> result = new List <Models.FileViewModel>(); try { foreach (string fileName in Directory.GetFiles(userFolder)) { FileInfo info = new FileInfo(fileName); // delete all file try { File.Delete(info.FullName); } catch { } } } catch (Exception ex) { notification.Type = Library.DTO.NotificationType.Error; notification.Message = ex.Message; } return(Ok(new Library.DTO.ReturnData <IEnumerable <Models.FileViewModel> >() { Data = result, Message = notification, TotalRows = totalRows })); }