Пример #1
0
        public ActionResult Move()
        {
            var vm = new MoveServiceDomainViewModel();

            if (_appUserContext.Current.CurrentCustomer != null)
            {
                var serviceDesks = _serviceDeskService
                                   .GetByCustomer(_appUserContext.Current.CurrentCustomer.Id)
                                   .ToList();
                vm.ServiceDesks.AddRange(serviceDesks
                                         .Select(s => new KeyValuePair <int, string>(s.Id, s.DeskName)));
            }
            return(PartialView("_Move", vm));
        }
Пример #2
0
        public JsonResult Move(MoveServiceDomainViewModel model)
        {
            var result = new { Success = "True", Message = "Success" };

            if (ModelState.IsValid)
            {
                try
                {
                    var userName    = _contextManager.UserManager.Name;
                    var dateTimeNow = DateTime.Now;
                    var customerId  = _appUserContext.Current.CurrentCustomer.Id;

                    var serviceDomain = _serviceDomainService.GetByCustomerAndId(customerId, model.ServiceDomainId);
                    if (serviceDomain != null)
                    {
                        serviceDomain.UpdatedBy     = userName;
                        serviceDomain.UpdatedDate   = dateTimeNow;
                        serviceDomain.ServiceDeskId = model.ServiceDeskId;

                        _serviceDomainService.Update(serviceDomain);
                    }
                }
                catch (Exception ex)
                {
                    _contextManager.ResponseManager.StatusCode = 500;
                    _contextManager.ResponseManager.AppendHeader(ModelStateErrorNames.ErrorMessage, ex.Message);
                    result = new { Success = "False", ex.Message };
                }
            }
            else
            {
                var errors = ModelState.GetModelStateMesssages();
                result = new { Success = "False", Message = errors.First() };
            }

            return(Json(result, JsonRequestBehavior.AllowGet));
        }