Example #1
0
        public ActionResult Move()
        {
            var vm = new MoveServiceFunctionViewModel();

            if (_appUserContext.Current.CurrentCustomer != null)
            {
                var serviceDomains = _serviceDomainService
                                     .GetByCustomer(_appUserContext.Current.CurrentCustomer.Id)
                                     .ToList();

                vm.ServiceDomains.AddRange(serviceDomains
                                           .Select(s => new KeyValuePair <int, string>(s.Id, s.ServiceDesk.DeskName + UnicodeCharacters.DoubleArrowRight + (string.IsNullOrEmpty(s.AlternativeName) ? s.DomainType.DomainName : s.AlternativeName))));
            }
            return(PartialView("_Move", vm));
        }
Example #2
0
        public JsonResult Move(MoveServiceFunctionViewModel model)
        {
            var result = new { Success = "True", Message = "Success" };

            if (ModelState.IsValid)
            {
                try
                {
                    var userName    = _contextManager.UserManager.Name;
                    var dateTimeNow = DateTime.Now;

                    var serviceFunction = _serviceFunctionService.GetById(model.ServiceFunctionId);
                    if (serviceFunction != null)
                    {
                        serviceFunction.UpdatedBy       = userName;
                        serviceFunction.UpdatedDate     = dateTimeNow;
                        serviceFunction.ServiceDomainId = model.ServiceDomainId;

                        _serviceFunctionService.Update(serviceFunction);
                    }
                }
                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));
        }