Пример #1
0
        public JsonResult EditDestination(DestinationViewModel model)
        {
            var operationResult = new OperationResult();

            Destination destination = new DestinationConverter().ConvertToDomain(model);

            operationResult = _destinationRepository.UpdateDestination(destination);

            if (operationResult.Success)
            {
                model.Success = true;

                var destinations = new List <DestinationViewModel>();

                var tempDestinations = _destinationRepository.GetDestinations().Where(x => x.IsActive).ToList();

                if (tempDestinations != null && tempDestinations.Count > 0)
                {
                    foreach (var tempDestination in tempDestinations)
                    {
                        DestinationViewModel convertedModel = new DestinationConverter().ConvertToView(tempDestination);

                        destinations.Add(convertedModel);
                    }
                }

                model.Destinations = destinations.OrderBy(x => x.DestinationDescription).ToList();
            }
            else
            {
                model.Success = false;
                model.Message = operationResult.Message;
            }

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