public List <IQueryFilter> GetFilters() { var result = new List <IQueryFilter>(); var refObj = new AU_MENU(); if (!string.IsNullOrEmpty(this.MenuId)) { result.Add(new QueryFilterLinQ { Property = ClassHelper.GetProperty(() => refObj.MenuId), Value = this.MenuId, Method = FilterMethod.Like }); } if (!string.IsNullOrEmpty(this.Title)) { result.Add(new QueryFilterLinQ { Property = ClassHelper.GetProperty(() => refObj.Title), Value = this.Title, Method = FilterMethod.Like }); } if (!string.IsNullOrEmpty(this.MenuIdCha)) { result.Add(new QueryFilterLinQ { Property = ClassHelper.GetProperty(() => refObj.MenuIdCha), Value = this.MenuIdCha, Method = FilterMethod.Like }); } return(result); }
public AU_MENU GetByMenuId(string menuId) { var menu = new AU_MENU(); menu = string.IsNullOrEmpty(menuId) ? null : menu = _service.Repository.DbSet.FirstOrDefault(x => x.MenuId == menuId); return(menu); }
public async Task <IHttpActionResult> Put(string id, AU_MENU instance) { var result = new TransferObj <AU_MENU>(); if (id != instance.Id) { result.Status = false; result.Message = "Id không hợp lệ"; return(Ok(result)); } try { var item = _service.Update(instance); _service.UnitOfWork.Save(); result.Status = true; result.Data = item; return(Ok(result)); } catch (Exception e) { result.Status = false; result.Message = e.Message; return(Ok(result)); } }
public async Task <IHttpActionResult> Post(AU_MENU instance) { var result = new TransferObj <AU_MENU>(); try { var item = _service.Insert(instance); _service.UnitOfWork.Save(); result.Status = true; result.Data = item; } catch (Exception e) { result.Status = false; result.Message = e.Message; return(Ok(result)); } return(CreatedAtRoute("DefaultApi", new { controller = this, id = instance.Id }, result)); }
public async Task <IHttpActionResult> Delete(string id) { AU_MENU instance = await _service.Repository.FindAsync(id); if (instance == null) { return(NotFound()); } try { _service.Delete(instance.Id); await _service.UnitOfWork.SaveAsync(); return(Ok(instance)); } catch (Exception) { return(InternalServerError()); } }