Esempio n. 1
0
        public ActionResult Create(SkillViewModel skillViewModel)
        {
            try
            {
                //Leading and trailing empty spaces are trimmed
                skillViewModel.SkillName        = skillViewModel.SkillName.Trim();
                skillViewModel.SkillDescription = skillViewModel.SkillDescription.Trim();
                var skillCreateResult = _skillService.Create(skillViewModel.ToDTO());

                //-1 is returned if new Skill has already existing Skill Name
                if (skillCreateResult == -1)
                {
                    ModelState.AddModelError("SkillName", "Skill Name Already Exists");
                    return(View(skillViewModel));
                }
                else if (skillCreateResult == 0)
                {
                    ViewBag.Message = "Db Creation Error! Please Restart Application";
                }
                //Notification Message is stored in tempdata
                TempData["message"] = "Successfully Added Skill";
                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Esempio n. 2
0
 public async Task CreateSkill(SkillTagDto skill)
 {
     using (var unitOfWork = UnitOfWorkProvider.Create())
     {
         skillService.Create(skill);
         await unitOfWork.Commit();
     }
 }
Esempio n. 3
0
        public IActionResult Post([FromBody] CreateSkillViewModel vm)
        {
            return(ApiAction(() =>
            {
                var contract = _mapper.Map <CreateSkillContract>(vm);
                var returnContract = _skillService.Create(contract);

                return Created("Get", _mapper.Map <CreatedSkillViewModel>(returnContract));
            }));
        }
 public async Task <ActionResult> CreateSkill(SkillViewModel model)
 {
     if (ModelState.IsValid)
     {
         var skillDTO = _mapper.Map <SkillViewModel, SkillDTO>(model);
         skillDTO.Id = new SkillDTO().Id;
         await _skillService.Create(skillDTO);
     }
     return(RedirectToAction("Skills")); // todo  returnUrl
 }
Esempio n. 5
0
        public async Task <IActionResult> Create([FromBody] SkillCreateRequest request)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }
            var result = await _skillService.Create(request);

            if (!result.IsSuccessed)
            {
                return(BadRequest(result));
            }
            return(Ok(result));
        }
Esempio n. 6
0
        public IActionResult Create(CreateSkillRequest request)
        {
            try
            {
                var skillToCreate = _service.Create(request.Name);

                var dto = _mapper.Map <SkillDto>(skillToCreate);

                return(CreatedAtAction(nameof(GetById), new { id = skillToCreate.Id }, dto));
            }
            catch (Exception ex)
            {
                return(StatusCode(500, ex.Message));
            }
        }
Esempio n. 7
0
 public ActionResult <SkillDto> Create([FromHeader] Guid token, [FromBody] SkillDto skill)
 {
     try
     {
         ValidateToken(token);
         return(Ok(_skillService.Create(skill)));
     }
     catch (AuthenticationException)
     {
         return(Unauthorized());
     }
     catch (ArgumentException e)
     {
         return(NotFound(e.Message));
     }
 }
        public string Create(string name, string description)
        {
            string msg = "";

            try
            {
                var userid = User.Identity.GetUserId();
                service.Create(new Skill {
                    Name = name, Description = description, CreatedBy = userid, ChangedBy = userid
                });
            }
            catch (Exception ex)
            {
                msg = "Error occured:" + ex.Message;
            }
            return(msg);
        }
Esempio n. 9
0
 public ActionResult <SkillDto> Create([FromBody] SkillDto createBody)
 {
     return(Created("", _skillService.Create(createBody)));
 }
Esempio n. 10
0
 public Task <SkillCategoryItem> Create(SkillCategoryCreateContract contract)
 {
     return(_service.Create(contract));
 }
 public BaseResponse <SkillOutputDto> Create([FromBody] SkillInputDto skill)
 {
     return(_skillService.Create(skill));
 }