Пример #1
0
        public IActionResult setRoute([FromBody] Route newRoute)
        {
            int    count       = 0;
            string errorString = null;

            try
            {
                newRoute.OrgId           = Int32.Parse(User.Claims.FirstOrDefault(x => x.Type.Equals("OrgId")).Value);
                newRoute.CreatedByUserId = Int32.Parse(User.Claims.FirstOrDefault(x => x.Type.Equals("UserId")).Value);
                RouteModel        RouteModel = new RouteModel();
                OrganizationModel orgModel   = new OrganizationModel();
                count          = RouteModel.GetRoutesCountByOrgId(newRoute.OrgId, out errorString);
                newRoute.Name  = orgModel.getOrganizationById(newRoute.OrgId, out errorString).Name;
                newRoute.Name += " " + (count + 1);

                newRoute.RouteId = RouteModel.AddNewRoute(newRoute, out errorString);
                RouteObj obj = new RouteObj(newRoute);
                return(new JsonResult(obj));
            }
            catch (Exception e)
            {
                return(Ok(e + "\n" + errorString));
            }
        }