public async Task <bool> Delete(FoodGrouping FoodGrouping) { if (await ValidateId(FoodGrouping)) { } return(FoodGrouping.IsValidated); }
public FoodGrouping_FoodGroupingDTO(FoodGrouping FoodGrouping) { this.Id = FoodGrouping.Id; this.Name = FoodGrouping.Name; this.StatusId = FoodGrouping.StatusId; this.Errors = FoodGrouping.Errors; }
public Task FilterItems() { var cleanSearchTerm = SearchTerm.ToLower().Trim(); TaskCompletionSource <bool> tcs = new TaskCompletionSource <bool>(); if (String.IsNullOrWhiteSpace(cleanSearchTerm)) { FoodList = oldFoodList; } else { List <Food> filteredFood = new List <Food>(); var foodList = oldFoodList; foreach (var item in foodList) { if (item.Where(c => c.name.ToLower().Contains(cleanSearchTerm)).Count() > 0) { foreach (var food in item) { if (food.name.ToLower().Contains(cleanSearchTerm)) { filteredFood.Add(food); } } } } FoodGrouping foodGrouping = new FoodGrouping(); FoodList = foodGrouping.CreateGroupsFromData(filteredFood); } tcs.SetResult(true); return(tcs.Task); }
public async Task <FoodGrouping> Create(FoodGrouping FoodGrouping) { if (!await FoodGroupingValidator.Create(FoodGrouping)) { return(FoodGrouping); } try { await UOW.Begin(); await UOW.FoodGroupingRepository.Create(FoodGrouping); await UOW.Commit(); await Logging.CreateAuditLog(FoodGrouping, new { }, nameof(FoodGroupingService)); return(await UOW.FoodGroupingRepository.Get(FoodGrouping.Id)); } catch (Exception ex) { await UOW.Rollback(); await Logging.CreateSystemLog(ex.InnerException, nameof(FoodGroupingService)); if (ex.InnerException == null) { throw new MessageException(ex); } else { throw new MessageException(ex.InnerException); } } }
public void RefreshList() { var foodList = DatabaseConnection.Connection.QueryAsync <Food>("SELECT * FROM Food"); var listToSort = foodList.Result; FoodGrouping foodGrouping = new FoodGrouping(); FoodList = foodGrouping.CreateGroupsFromData(listToSort); oldFoodList = FoodList; }
protected override void ViewIsAppearing(object sender, EventArgs e) { base.ViewIsAppearing(sender, e); var foodList = DatabaseConnection.Connection.QueryAsync <Food>("SELECT * FROM Food WHERE blacklisted = 0 ORDER BY name"); var listToSort = foodList.Result; FoodGrouping foodGrouping = new FoodGrouping(); FoodList = foodGrouping.CreateGroupsFromData(listToSort); }
private FoodGrouping ConvertDTOToEntity(FoodGrouping_FoodGroupingDTO FoodGrouping_FoodGroupingDTO) { FoodGrouping FoodGrouping = new FoodGrouping(); FoodGrouping.Id = FoodGrouping_FoodGroupingDTO.Id; FoodGrouping.Name = FoodGrouping_FoodGroupingDTO.Name; FoodGrouping.StatusId = FoodGrouping_FoodGroupingDTO.StatusId; FoodGrouping.BaseLanguage = CurrentContext.Language; return(FoodGrouping); }
public async Task <FoodGrouping> Get(long Id) { FoodGrouping FoodGrouping = await UOW.FoodGroupingRepository.Get(Id); if (FoodGrouping == null) { return(null); } return(FoodGrouping); }
public async Task <ActionResult <FoodGrouping_FoodGroupingDTO> > Get([FromBody] FoodGrouping_FoodGroupingDTO FoodGrouping_FoodGroupingDTO) { if (!ModelState.IsValid) { throw new BindException(ModelState); } FoodGrouping FoodGrouping = await FoodGroupingService.Get(FoodGrouping_FoodGroupingDTO.Id); return(new FoodGrouping_FoodGroupingDTO(FoodGrouping)); }
public async Task <bool> Create(FoodGrouping FoodGrouping) { FoodGroupingDAO FoodGroupingDAO = new FoodGroupingDAO(); FoodGroupingDAO.Id = FoodGrouping.Id; FoodGroupingDAO.Name = FoodGrouping.Name; FoodGroupingDAO.StatusId = FoodGrouping.StatusId; DataContext.FoodGrouping.Add(FoodGroupingDAO); await DataContext.SaveChangesAsync(); FoodGrouping.Id = FoodGroupingDAO.Id; await SaveReference(FoodGrouping); return(true); }
public async Task <FoodGrouping> Get(long Id) { FoodGrouping FoodGrouping = await DataContext.FoodGrouping.Where(x => x.Id == Id).Select(x => new FoodGrouping() { Id = x.Id, Name = x.Name, StatusId = x.StatusId, }).AsNoTracking().FirstOrDefaultAsync(); if (FoodGrouping == null) { return(null); } return(FoodGrouping); }
public async Task <bool> Update(FoodGrouping FoodGrouping) { FoodGroupingDAO FoodGroupingDAO = DataContext.FoodGrouping.Where(x => x.Id == FoodGrouping.Id).FirstOrDefault(); if (FoodGroupingDAO == null) { return(false); } FoodGroupingDAO.Id = FoodGrouping.Id; FoodGroupingDAO.Name = FoodGrouping.Name; FoodGroupingDAO.StatusId = FoodGrouping.StatusId; await DataContext.SaveChangesAsync(); await SaveReference(FoodGrouping); return(true); }
public async Task <bool> ValidateId(FoodGrouping FoodGrouping) { FoodGroupingFilter FoodGroupingFilter = new FoodGroupingFilter { Skip = 0, Take = 10, Id = new IdFilter { Equal = FoodGrouping.Id }, Selects = FoodGroupingSelect.Id }; int count = await UOW.FoodGroupingRepository.Count(FoodGroupingFilter); if (count == 0) { FoodGrouping.AddError(nameof(FoodGroupingValidator), nameof(FoodGrouping.Id), ErrorCode.IdNotExisted); } return(count == 1); }
public async Task <ActionResult <FoodGrouping_FoodGroupingDTO> > Create([FromBody] FoodGrouping_FoodGroupingDTO FoodGrouping_FoodGroupingDTO) { if (!ModelState.IsValid) { throw new BindException(ModelState); } FoodGrouping FoodGrouping = ConvertDTOToEntity(FoodGrouping_FoodGroupingDTO); FoodGrouping = await FoodGroupingService.Create(FoodGrouping); FoodGrouping_FoodGroupingDTO = new FoodGrouping_FoodGroupingDTO(FoodGrouping); if (FoodGrouping.IsValidated) { return(FoodGrouping_FoodGroupingDTO); } else { return(BadRequest(FoodGrouping_FoodGroupingDTO)); } }
private async Task SaveReference(FoodGrouping FoodGrouping) { }
public async Task <bool> Delete(FoodGrouping FoodGrouping) { await DataContext.FoodGrouping.Where(x => x.Id == FoodGrouping.Id).DeleteFromQueryAsync(); return(true); }
public async Task <bool> Create(FoodGrouping FoodGrouping) { return(FoodGrouping.IsValidated); }