public static SaleExtrasModel EntityToModel(this SaleExtras entity, bool virtualActive = false)
 {
     try
     {
         SaleExtrasModel model = new SaleExtrasModel()
         {
             ExtraProductId = entity.ExtraProductId,
             ProductAmount  = entity.ProductAmount,
             ProductUnit    = entity.ProductUnit,
             RoomSaleId     = entity.RoomSaleId,
             IsActive       = entity.IsActive,
             Id             = entity.Id
         };
         if (virtualActive)
         {
             model.RoomSale     = entity.RoomSale;
             model.ExtraProduct = entity.ExtraProduct;
         }
         return(model);
     }
     catch (Exception)
     {
         return(new SaleExtrasModel());
     }
 }
        public static SaleExtras ModelToEnity(this SaleExtrasModel model, bool virtualActive = false)
        {
            SaleExtras entity = new SaleExtras()
            {
                 ExtraProductId=model.ExtraProductId,
                  ProductAmount=model.ProductAmount,
                   ProductUnit=model.ProductUnit,
                    RoomSaleId=model.RoomSaleId,
                Id = model.Id,
                IsActive = model.IsActive
            };
            if (virtualActive)
            {
                entity.RoomSale = model.RoomSale;
                entity.ExtraProduct = model.ExtraProduct;

            }
            return entity;
        }
        public static SaleExtras ModelToEnity(this SaleExtrasModel model, bool virtualActive = false)
        {
            SaleExtras entity = new SaleExtras()
            {
                ExtraProductId = model.ExtraProductId,
                ProductAmount  = model.ProductAmount,
                ProductUnit    = model.ProductUnit,
                RoomSaleId     = model.RoomSaleId,
                Id             = model.Id,
                IsActive       = model.IsActive
            };

            if (virtualActive)
            {
                entity.RoomSale     = model.RoomSale;
                entity.ExtraProduct = model.ExtraProduct;
            }
            return(entity);
        }
        public ActionResult SaleExtrasInsert(SaleExtrasModel model, int id)
        {
            var rezervasyon = _serviceRoomSales.GetById(id).Room.Number + " : " + _serviceRoomSales.GetById(id).LoginDate + "-" + _serviceRoomSales.GetById(id).LogoutDate;

            var Urunler = _serviceExtraProducts.GetExtraProducts(_serviceRoomSales.GetById(id).PacketId).Select(x => new SelectListItem {
                Text = x.Name, Value = x.Id.ToString()
            }).ToList();

            ViewBag.Rezervasyon = rezervasyon;
            ViewBag.Urunler     = Urunler;

            SaleExtras yeni = new SaleExtras
            {
                ExtraProductId = model.ExtraProductId,
                ProductAmount  = model.ProductAmount,
                ProductUnit    = model.ProductUnit,
                RoomSaleId     = model.RoomSaleId
            };

            _serviceSaleExtras.Insert(yeni);

            return(RedirectToAction("SaleExtrasList"));
        }
        public ActionResult SaleExtrasInsert(SaleExtrasModel model,int id)
        {
            var rezervasyon = _serviceRoomSales.GetById(id).Room.Number + " : " + _serviceRoomSales.GetById(id).LoginDate + "-" + _serviceRoomSales.GetById(id).LogoutDate;

            var Urunler = _serviceExtraProducts.GetExtraProducts(_serviceRoomSales.GetById(id).PacketId).Select(x => new SelectListItem { Text = x.Name, Value = x.Id.ToString() }).ToList();
            ViewBag.Rezervasyon = rezervasyon;
            ViewBag.Urunler = Urunler;

            SaleExtras yeni = new SaleExtras
            {
                ExtraProductId = model.ExtraProductId,
                ProductAmount = model.ProductAmount,
                ProductUnit = model.ProductUnit,
                RoomSaleId = model.RoomSaleId
            };

            _serviceSaleExtras.Insert(yeni);

            return RedirectToAction("SaleExtrasList");
        }