public JsonResult AddVessel(VesselViewModel model) { var operationResult = new OperationResult(); Vessel newVessel = new VesselConverter().ConvertToDomain(model); operationResult = _vesselRepository.SaveVessel(newVessel); if (operationResult.Success) { model.Success = true; var vessels = new List <VesselViewModel>(); var tempVessels = _vesselRepository.GetVessels().Where(x => x.IsActive).ToList(); if (tempVessels != null && tempVessels.Count > 0) { foreach (var tempVessel in tempVessels) { VesselViewModel convertedModel = new VesselConverter().ConvertToView(tempVessel); vessels.Add(convertedModel); } } model.Vessels = vessels.OrderBy(x => x.VesselName).ToList(); } else { model.Success = false; model.Message = operationResult.Message; } return(Json(model, JsonRequestBehavior.AllowGet)); }