public ActionResult EditStepResource(int?roadStepId, int?id)
        {
            var model = new ManageStepResourceViewModel();

            if (id != null)
            {
                var stepResource = Db.StepResources
                                   .FirstOrDefault(p => p.Id == id);
                if (stepResource != null)
                {
                    model.Id          = stepResource.Id;
                    model.Name        = stepResource.Name;
                    model.Description = stepResource.Description;

                    if (roadStepId != null)
                    {
                        model.RoadStepId = roadStepId;
                    }
                }
            }

            return(View(model));
        }
        public ActionResult EditStepResource(ManageStepResourceViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            StepResource stepResource = null;

            if (model.Id != null)
            {
                stepResource = Db.StepResources.FirstOrDefault(p => p.Id == model.Id);
                if (stepResource != null)
                {
                    stepResource.Name        = model.Name;
                    stepResource.Description = model.Description;
                }
            }
            else
            {
                var currentUserId = User.Identity.GetUserId();

                RoadStep roadStep = null;
                if (model.RoadStepId != null)
                {
                    roadStep = Db.RoadSteps.FirstOrDefault(p => p.Id == model.RoadStepId);
                }

                stepResource = new StepResource(model.Name, model.Description, currentUserId, roadStep);
                Db.StepResources.Add(stepResource);
            }

            Db.SaveChanges();

            return(RedirectToAction("EditRoadStep", new { @id = model.RoadStepId }));
        }