public Result UpsertItem(ItemDto itemDto) { try { if (itemDto.Mode == EnumCrudMode.Create) { ItemRepo.AddItem(itemDto); } else if (itemDto.Mode == EnumCrudMode.Update) { ItemRepo.UpdateItem(itemDto); } else if (itemDto.Mode == EnumCrudMode.Delete) { ItemRepo.DeleteItem(itemDto); } return(new Result() { ResultCode = EnumResultCode.OK, Dto = itemDto }); } catch (Exception ex) { return(new Result() { ResultCode = EnumResultCode.Error, Details = ex.Message, Dto = itemDto }); } }
private async void BtnAddItem_Click(object sender, EventArgs e) { if (await ItemRepo.AddItem(edtName.Text, category, Double.Parse(edtPrice.Text), edtCity.Text, user.Id, condition, edtDescription.Text, "example.jpg")) { Toast.MakeText(this, "Item added", ToastLength.Long).Show(); } else { Toast.MakeText(this, "Item failed", ToastLength.Long).Show(); } }
public bool CreateItem(Item i) { _i = i; ItemRepo repo = new ItemRepo(); //pending //i.ItemStatus = 1; i.ItemStatus = ItemStatusType.Pending; Validate(); if (Errors.Count == 0) { return(repo.AddItem(_i)); } return(false); }
public Item AddItem(Item newItem) { return(_repo.AddItem(newItem)); }