Ejemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,Name,Description,IsActive,UserCreate,DateCreate,UserUpdate,DateUpdate")] ClientTypeModel clientTypeModel)
        {
            if (id != clientTypeModel.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(clientTypeModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ClientTypeModelExists(clientTypeModel.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(clientTypeModel));
        }
Ejemplo n.º 2
0
 public ActionResult Add(ClientTypeModel model)
 {
     if (ModelState.IsValid)
     {
         ClientType clientType = model.MapTo <ClientTypeModel, ClientType>();
         _clientTypeService.Insert(clientType);
         return(RedirectToAction("Index"));
     }
     return(View(model));
 }
 public static ClientTypeDto ToDto(this ClientTypeModel clientType)
 {
     return(new ClientTypeDto()
     {
         ClientTypeId = clientType.ClientTypeId,
         MinutePrice = clientType.MinutePrice,
         SMSPrice = clientType.SMSPrice,
         TypeName = clientType.TypeName,
         //Clients = clientType.Clients.Select(c => c.ToDto()).ToList()
     });
 }
Ejemplo n.º 4
0
 public ActionResult Edit(ClientTypeModel model)
 {
     if (ModelState.IsValid)
     {
         ClientType clientType = model.MapTo <ClientTypeModel, ClientType>();
         _clientTypeService.Update(clientType);
         SuccessNotification($"{_localizationService.GetResource("UpdateSuccess") }");
         return(RedirectToAction("Index"));
     }
     return(View(model));
 }
Ejemplo n.º 5
0
        public async Task <IActionResult> Create([Bind("Name,Description")] ClientTypeModel clientTypeModel)
        {
            if (ModelState.IsValid)
            {
                clientTypeModel.UserCreate = User.Identity.Name;
                _context.Add(clientTypeModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(clientTypeModel));
        }
        /// <summary>
        /// To the model.
        /// </summary>
        /// <param name="entity">The entity.</param>
        /// <returns></returns>
        public static ClientTypeModel ToModel(this ClientTypeViewModel entity)
        {
            if (entity == null)
            {
                return(null);
            }

            var model = new ClientTypeModel
            {
                ClientTypeID = entity.ClientTypeID,
                ClientType   = entity.ClientType
            };

            return(model);
        }
        /// <summary>
        /// To the view model.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <returns></returns>
        public static ClientTypeViewModel ToViewModel(this ClientTypeModel model)
        {
            if (model == null)
            {
                return(null);
            }

            var entity = new ClientTypeViewModel
            {
                ClientTypeID = model.ClientTypeID,
                ClientType   = model.ClientType
            };

            return(entity);
        }
Ejemplo n.º 8
0
 public static CRMServiceReference.ClientTypeDto ToDto(this ClientTypeModel clientType)
 {
     if (clientType == null)
     {
         return(null);
     }
     return(new CRMServiceReference.ClientTypeDto()
     {
         ClientTypeId = clientType.ClientTypeId,
         MinutePrice = clientType.MinutePrice,
         SMSPrice = clientType.SMSPrice,
         TypeName = clientType.TypeName,
         //Clients = clientType.Clients.Select(c => c.ToDto()).ToList()
     });
 }
Ejemplo n.º 9
0
        public ActionResult Add()
        {
            ClientTypeModel model = new ClientTypeModel();

            return(View(model));
        }