public IActionResult CreatePlan(PlanDTO plan)
        {
            _loggerManager.Info($"CreatePlan is requested");

            Response.StatusCode = StatusCodes.Status202Accepted;

            if (ModelState.IsValid)
            {
                var result = _planRepository.CreatePlan(plan, HttpContext.GetUserId());

                if (result)
                {
                    _loggerManager.Info($"CreatePlan successfully created a plan");
                    Response.StatusCode = StatusCodes.Status201Created;
                }
                else
                {
                    _loggerManager.Warn($"CreatePlan was unable to create a plan");
                    ModelState.AddModelError(string.Empty, sharedResource.worksheetCreatePlanProblem);
                }
            }
            else
            {
                _loggerManager.Info($"CreatePlan request is invalid");
            }

            return(PartialView("~/Views/Worksheet/Partials/_NewPlan.cshtml"));
        }
Example #2
0
        public IActionResult Create(PlanViewModel model)
        {
            ViewBag.Labels = _planRepository.GetAllLabels();

            if (ModelState.IsValid)
            {
                var plan = _mapper.Map <PlanViewModel, Plan>(model);

                plan.AddedBy = _admin.Fullname;

                _planRepository.CreatePlan(plan);

                return(RedirectToAction("index"));
            }
            return(View(model));
        }
Example #3
0
        public IActionResult Create([FromBody] Plan plan)
        {
            var result = _repo.CreatePlan(plan, _user.Id);

            return(Created(string.Empty, result));
        }