public async Task <ActionResult> Dropdown(string q = null, int limit = 20) { var result = new ApiResultModel <IEnumerable <DropdownItem> >(); var data = await _storage.GetRepository <IGoods_Repository>().DropdownListAsync(q, limit); if (data != null) { result.Data = data; return(Ok(result)); } else { result.BadRequest("Cannot remove data"); return(BadRequest(result)); } }
public async Task <ActionResult> Create(Tags_Group idata) { var result = new ApiResultModel <Tags_Group>(); var data = await _storage.GetRepository <ITagsGroup_Repository>().CreateAsync(idata); if (data != null) { result.Data = data; return(Ok(result)); } else { result.BadRequest(); return(BadRequest(result)); } }
public async Task <ActionResult> Delete(Guid id) { var result = new ApiResultModel <bool>(); var data = await this._storage.GetRepository <IGoods_Repository>().DeleteAsync(id); if (data) { result.Data = data; return(Ok(result)); } else { result.BadRequest("Cannot delete data"); return(BadRequest(result)); } }
public async Task <ActionResult> Remove(int id) { var result = new ApiResultModel <bool>(); var data = await this._storage.GetRepository <ITagsGroup_Repository>().RemoveAsync(id); if (data) { result.Data = data; return(Ok(result)); } else { result.BadRequest("Cannot remove data"); return(BadRequest(result)); } }
public async Task <ActionResult> ListAsync() { var result = new ApiResultModel <List <Tags_Group> >(); var data = await this._storage.GetRepository <ITagsGroup_Repository>().ListAsync(x => x.name != null, 0); if (data != null) { result.Data = data; return(Ok(result)); } else { result.BadRequest("Cannot delete data"); return(BadRequest(result)); } }
public async Task <ActionResult> Authen(UserLoginModel idata) { var result = new ApiResultModel <UserInfoModel>(); var data = await _userService.Authenticate(idata.email, idata.password); if (data != null) { result.Data = data; return(Ok(result)); } else { result.BadRequest(); return(BadRequest(result)); } }
public async Task <ActionResult> CheckArea(Warehouse_Area idata) { var result = new ApiResultModel <Warehouse_Area>(); var data = await this._storage.GetRepository <IWarehouse_Repository>().CheckArea(idata); if (data != null) { result.Data = data; return(Ok(result)); } else { result.BadRequest("Please check your data"); return(BadRequest(result)); } }
public async Task <ActionResult> Update(Guid id, Comments idata) { var result = new ApiResultModel <Comments>(); var data = await this._storage.GetRepository <IComments_Repository>().UpdateAsync(idata); if (data != null) { result.Data = data; return(Ok(result)); } else { result.BadRequest("Cannot edit data"); return(BadRequest(result)); } }
public async Task <ActionResult> Create(Goods idata) { var result = new ApiResultModel <Goods>(); var data = await this._storage.GetRepository <IGoods_Repository>().CreateAsync(idata); if (data != null) { result.Data = data; return(Ok(result)); } else { result.BadRequest("Cannot save data"); return(BadRequest(result)); } }
public async Task <ActionResult> Create(Permission_Access idata) { var result = new ApiResultModel <Permission_Access>(); var data = await _storage.GetRepository <IPermission_Repository>().CreateAsync(idata); if (data != null) { result.Data = data; return(Ok(result)); } else { result.BadRequest(); return(BadRequest(result)); } }
public async Task <ActionResult> ListAsync() { var result = new ApiResultModel <List <Permission_Access> >(); var data = await this._storage.GetRepository <IPermission_Repository>().ListAsync(x => x.is_active == true, 0); if (data != null) { result.Data = data; return(Ok(result)); } else { result.BadRequest("Cannot delete data"); return(BadRequest(result)); } }
public async Task <ActionResult> Items(string q = null, int limit = 20) { var result = new ApiResultModel <IEnumerable <Goods> >(); var data = await _storage.GetRepository <IGoods_Repository>().ItemsAynce(q, limit); if (data != null) { result.Data = data; return(Ok(result)); } else { result.BadRequest("No data found"); return(BadRequest(result)); } }
private IActionResult GetKey(byte[] keystore) { var result = new ApiResultModel <ApiClientInfo>(); if (keystore != null) { result.Data = new ApiClientInfo() { ip = _client.GetClientIP(), ua = _client.GetUserAgent(), client_id = client_id, key = Encoding.UTF8.GetString(keystore) }; return(Ok(result)); } else { result.BadRequest("Cannot generate API key"); return(BadRequest(result)); } }
public async Task <ActionResult> Index(int id) { if (id < 1) { return(BadRequest(new ApiResultError(404))); } var result = new ApiResultModel <FileStore_FileType>(); var data = await _storage.GetRepository <IFileStore_Type_Repository>().GetAsync(x => x.id == id); if (data != null) { result.Data = data; return(Ok(result)); } else { result.BadRequest("Data not found"); return(NotFound(result)); } }
public async Task <ActionResult> Index(Guid id) { if (id == Guid.Empty) { return(BadRequest(new ApiResultError(404))); } var result = new ApiResultModel <Contents>(); var data = await this._storage.GetRepository <IContents_Repository>().GetAsync(x => x.id == id); if (data != null) { result.Data = data; return(Ok(result)); } else { result.BadRequest("Data not found"); return(NotFound(result)); } }
public async Task <ActionResult> Tags(int id, string q = null, int limit = 20) { if (id < 1) { throw new ArgumentNullException("CMS Category ID is required"); } var result = new ApiResultModel <IEnumerable <DropdownItem> >(); var data = await _storage.GetRepository <ICategory_Repository>().TagsDropdownAsync(id, q, limit); if (data != null) { result.Data = data; return(Ok(result)); } else { result.BadRequest("No data found"); return(BadRequest(result)); } }
public async Task <ApiResultModel <FileStore_Images> > SaveImage(string mudule, IFormFile file, bool isPublic = false, int width = 0, int height = 0) { var result = new ApiResultModel <FileStore_Images>(); if (mudule.isNOEOW()) { result.BadRequest("Module name is required"); return(result); } _module = mudule; try { if (file.Length > 0) { var file_extension = Path.GetExtension(file.FileName); var ext_data = await _storage.GetRepository <IFileStore_Type_Repository>().ListAsync(x => x.file_type == File_Types.Image && x.is_active == true); var check_type = ext_data.Where(x => x.file_extension == file_extension).FirstOrDefault(); if (check_type == null) { result.BadRequest($"File type not allowed, file must be ({(string.Join(",", ext_data.Select(x=>x.file_extension).ToArray()))})"); return(result); } string filename = Guid.NewGuid().ToString() + file_extension; string url_img = null; string path_img = null; string path = @"\"; IFileProxy fileProxy; if (isPublic && _appSetting.PublicDirectory != null) { path = $@"{_appSetting.PublicDirectory}\{_appSetting.FileStoreFolder}\{_module}\{ImagePath.Original}\"; if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } _fileStorage.CreateDirectoryProxy(path); fileProxy = _fileStorage.CreateFileProxy(path, filename); path_img = $@"{_appSetting.FileStoreFolder}/{_module}/"; url_img = $@"{path_img}{ImagePath.Thumbs}/{filename}"; } else { path = $@"{AppContext.BaseDirectory}{_appSetting.FileStoreFolder}\{_module}\{ImagePath.Original}\"; if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } fileProxy = _fileStorage.CreateFileProxy(path, filename); path_img = $@"FileStore/Image/"; url_img = $@"{path_img}{ImagePath.Thumbs}/{filename}"; } await fileProxy.WriteStreamAsync(file.OpenReadStream()); new ImageResize(path + filename).ToThumnail(width, height); if (url_img != null) { var data = await _storage.GetRepository <IFileStore_Images_Repository>().CreateAsync(new FileStore_Images() { file_type_id = check_type.id, module = _module, title = Path.GetFileNameWithoutExtension(file.FileName), is_public = isPublic, name = filename, url = url_img, check_sum = CryptographyCore.CreateCheckSUm_Stream(file.OpenReadStream()) }); result.Data = data; return(result); } else { result.BadRequest(); return(result); } } else { result.BadRequest("File is required"); return(result); } } catch (Exception e) { result.BadRequest(e.Message); return(result); } }