public ActionResult PacketEdit(PacketsModel model)
        {
            if (ModelState.IsValid)
            {
                _servicePackets.Update(model.ModelToEnity());
            }

            return(RedirectToAction("PacketList"));
        }
 public ActionResult PacketEdit(int id)
 {
     if (_servicePackets.GetById(id) != null)
     {
         PacketsModel model = _servicePackets.GetById(id).EntityToModel();
         return(View(model));
     }
     else
     {
         return(RedirectToAction("PacketList"));
     }
 }
예제 #3
0
        public static Packets ModelToEnity(this PacketsModel model, bool virtualActive = false)
        {
            Packets entity = new Packets()
            {
                Description     = model.Description,
                Name            = model.Name,
                PricePercentage = model.PricePercentage,
                Id       = model.Id,
                IsActive = model.IsActive
            };

            if (virtualActive)
            {
                entity.RoomSales = model.RoomSales;
                entity.PacketsExtraProductCategories = model.PacketsExtraProductCategories;
            }
            return(entity);
        }
예제 #4
0
 public static PacketsModel EntityToModel(this Packets entity, bool virtualActive = false)
 {
     try
     {
         PacketsModel model = new PacketsModel()
         {
             Description     = entity.Description,
             Name            = entity.Name,
             IsActive        = entity.IsActive,
             PricePercentage = entity.PricePercentage,
             Id = entity.Id
         };
         if (virtualActive)
         {
             model.RoomSales = entity.RoomSales;
             model.PacketsExtraProductCategories = entity.PacketsExtraProductCategories;
         }
         return(model);
     }
     catch (Exception)
     {
         return(new PacketsModel());
     }
 }