public void Save(Consumable model)
 {
     if (model.IsNew)
         CreatePostRequest(model);
     else
         CreatePutRequest(model.Id, model);
 }
        public void Can_SaveNewConsumable()
        {
            var consumable = new Consumable
                {
                    Id = Guid.NewGuid(),
                    Name = "Zat 1",
                    Type = (byte) ConsumableType.Feed,
                    Unit = "liter",
                    UnitPrice = 10000
                };

            var house = new HenHouse
                {
                    Id = Guid.NewGuid(),
                    Name = "House 1",
                    Depreciation = 100,
                    Active = true,
                    PurchaseCost = 100000
                };

            using (var conn = factory.OpenDbConnection())
            {
                conn.InsertParam(house);
                conn.InsertParam(consumable);
            }

            var usage = new Models.ConsumableUsage
                {
                    Total = 10000,
                    Date = DateTime.Today,
                    Details = new List<ConsumableUsageDetail>
                        {
                            new ConsumableUsageDetail
                                {
                                    ConsumableId = consumable.Id,
                                    Count = 10,
                                    HouseId = house.Id,
                                    SubTotal = 10000,
                                    UnitPrice = 100000
                                }
                        }
                };

            service.Save(usage);

            using (var conn = factory.OpenDbConnection())
            {
                var usageData = conn.FirstOrDefault<Models.Data.ConsumableUsage>(c => c.Date == usage.Date);
                var details = conn.Where<Models.Data.ConsumableUsageDetail>(new {UsageId = usageData.Id});
                Compare(usageData, details, usage);
            }
        }