示例#1
0
        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
                });
            }
        }
示例#2
0
 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();
     }
 }
示例#3
0
        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);
        }
示例#4
0
 public Item AddItem(Item newItem)
 {
     return(_repo.AddItem(newItem));
 }