public async void RemoveWithObjectAsync_GivenSkillExistsInMoreThanOneProjectAndUser_ReturnsSuccess() { var skillToDelete = new SkillDTO { Id = 1, Name = "Cooking" }; var projectsArray = new ProjectDTO[] { new ProjectDTO { Title = "Project1", Description = "Foo", Skills = new SkillDTO[] { skillToDelete } }, new ProjectDTO { Title = "Project2", Description = "Bar", Skills = new SkillDTO[] { skillToDelete } } }; skillRepositoryMock.Setup(c => c.FindAsync(skillToDelete.Id)).ReturnsAsync(skillToDelete); projectRepositoryMock.Setup(p => p.ReadDetailedAsync()).ReturnsAsync(projectsArray); userRepositoryMock.Setup(u => u.ReadAsync()).ReturnsAsync(new UserDTO[] { }); using (var logic = new SkillLogic(skillRepositoryMock.Object, userRepositoryMock.Object, projectRepositoryMock.Object)) { var response = await logic.RemoveWithObjectAsync(skillToDelete); Assert.Equal(ResponseLogic.SUCCESS, response); skillRepositoryMock.Verify(c => c.FindAsync(skillToDelete.Id)); skillRepositoryMock.Verify(c => c.DeleteAsync(It.IsAny <int>()), Times.Never()); projectRepositoryMock.Verify(p => p.ReadDetailedAsync()); userRepositoryMock.Verify(u => u.ReadAsync()); } }
public SkillDTO InsertSkill(SkillDTO data) { Skill dataToInsert = new Skill(); dataToInsert = SkillRequestFormatter.ConvertRespondentInfoFromDTO(data); return(SkillRequestFormatter.ConvertRespondentInfoToDTO(_unitOfWork.SkillRepository.Create(dataToInsert))); }
public async void UpdateAsync_GivenErrorUpdating_ReturnsERROR_UPDATING() { var skillToUpdate = new SkillDTO { Id = 1, Name = "Skill" }; var skillToUpdateWithChanges = new SkillDTO { Id = 1, Name = "Skill123" }; skillRepositoryMock.Setup(c => c.FindAsync(skillToUpdateWithChanges.Id)).ReturnsAsync(skillToUpdate); skillRepositoryMock.Setup(c => c.UpdateAsync(skillToUpdateWithChanges)).ReturnsAsync(false); using (var logic = new SkillLogic(skillRepositoryMock.Object, userRepositoryMock.Object, projectRepositoryMock.Object)) { var response = await logic.UpdateAsync(skillToUpdateWithChanges); Assert.Equal(ResponseLogic.ERROR_UPDATING, response); skillRepositoryMock.Verify(c => c.FindAsync(skillToUpdateWithChanges.Id)); skillRepositoryMock.Verify(c => c.UpdateAsync(skillToUpdateWithChanges)); } }
public async void UpdateAsync_GivenSkillExists_ReturnsSuccess() { var skillToUpdate = new SkillDTO { Id = 1, Name = "Skill" }; var skillToUpdateWithChanges = new SkillDTO { Id = 1, Name = "Skill123" }; skillRepositoryMock.Setup(c => c.FindAsync(skillToUpdateWithChanges.Id)).ReturnsAsync(skillToUpdate); skillRepositoryMock.Setup(c => c.UpdateAsync(skillToUpdateWithChanges)).ReturnsAsync(true); using (var logic = new SkillLogic(skillRepositoryMock.Object, userRepositoryMock.Object, projectRepositoryMock.Object)) { var response = await logic.UpdateAsync(skillToUpdateWithChanges); Assert.Equal(ResponseLogic.SUCCESS, response); skillRepositoryMock.Verify(c => c.FindAsync(skillToUpdateWithChanges.Id)); skillRepositoryMock.Verify(c => c.UpdateAsync(skillToUpdateWithChanges)); } }
public SaveResult InsertOrUpdate(SkillDTO skill) { try { using (OpenNosContext context = DataAccessHelper.CreateContext()) { long SkillVNum = skill.SkillVNum; Skill entity = context.Skill.FirstOrDefault(c => c.SkillVNum == SkillVNum); if (entity == null) { skill = insert(skill, context); return(SaveResult.Inserted); } skill = update(entity, skill, context); return(SaveResult.Updated); } } catch (Exception e) { Logger.Error(string.Format(Language.Instance.GetMessageFromKey("UPDATE_SKILL_ERROR"), skill.SkillVNum, e.Message), e); return(SaveResult.Error); } }
public int UpdateSkill(SkillDTO data) { Skill dataToUpdate = SkillRequestFormatter.ConvertRespondentInfoFromDTO(data); var res = _unitOfWork.SkillRepository.Update(dataToUpdate); return(res); }
public IHttpActionResult PutSkill(int id, SkillDTO skill) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != skill.SkillID) { return(BadRequest()); } try { db.Update(skill); } catch (DbUpdateConcurrencyException) { if (!SkillExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IActionResult Put(Guid SkillId, [FromBody] SkillDTO skill) { skill.SkillId = SkillId; Service.Update(skill); return(Ok(true)); }
public async Task CreateSkillTest() { // Arrange var client = SetupMock_Skill(); var config = new Mock <IConfiguration>(); client.BaseAddress = new Uri("https://localhost:1111/"); config.SetupGet(s => s["SkillsURL"]).Returns("https://localhost:1111/"); var service = new SkillService(null, new NullLogger <SkillService>(), config.Object) { Client = client }; // Act var newSkill = new SkillDTO { Id = 9, XpCost = 5, Name = "NEWSKILL" }; var result = await service.CreateSkill(newSkill); // Assert Assert.IsNotNull(result); Assert.AreEqual(newSkill.Id, result.Id); Assert.AreEqual(newSkill.Name, result.Name); Assert.AreEqual(newSkill.XpCost, result.XpCost); }
public async Task <ActionResult <Skill> > PostSkill(SkillDTO skill) { if (string.IsNullOrEmpty(skill.Name)) { return(BadRequest("Name cannot be empty")); } if (await _repository.GetSkill(skill.Id) != null) { var updSkill = new Skill { Id = skill.Id, Name = skill.Name, XpCost = skill.XpCost }; _repository.UpdateSkill(updSkill); await _repository.Save(); } var newSkill = new Skill { Id = skill.Id, Name = skill.Name, XpCost = skill.XpCost }; _repository.InsertSkill(newSkill); await _repository.Save(); return(CreatedAtAction("GetSkill", new { id = skill.Id }, skill)); }
public async Task <IHttpActionResult> NewSkill(SkillDTO newSkillDTO) { string userName = User.Identity.Name; User user = db.Users.Where(_user => _user.UserName == userName).SingleOrDefault(); if (user == null) { throw new HttpResponseException(HttpStatusCode.Unauthorized); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } Skill exist = db.Skills.SingleOrDefault(sec => sec.SkillName == newSkillDTO.SkillName); if (exist != null) { throw new HttpResponseException(HttpStatusCode.BadRequest); } newSkillDTO.Active = true; newSkillDTO.CreateDate = DateTime.Now; Skill skill = Mapper.Map <SkillDTO, Skill>(newSkillDTO); db.Skills.Add(skill); await db.SaveChangesAsync(); return(Ok(Mapper.Map <Skill, SkillDTO>(skill))); }
SkillDTO GetSkillDto(SKILL skill) { SkillDTO skillDto = new SkillDTO(); skillDto.id = skill.Id; skillDto.UserId = skill.UserId; skillDto.shortcutId = skill.ShortcutId; skillDto.nextLevel = skill.NextLevel; skillDto.coldTime = skill.ColdTime; skillDto.range = skill.Range; skillDto.applyValue = skill.ApplyValue; skillDto.applyTime = skill.ApplyTime; skillDto.mp = skill.Mp; skillDto.dis = skill.Dis; skillDto.back = skill.Back; skillDto.skillId = skill.SkillId; SkillModelDTO skillModelDto = new SkillModelDTO(); skillModelDto.code = skill.Code; skillModelDto.name = skill.Name; SkillInitial skillInitial = SkillInitialProperty.mapSkill[skillDto.skillId]; skillModelDto.info = skillInitial.info; skillModelDto.icon_name = skillInitial.icon_name; skillModelDto.applyType = skillInitial.applyType; skillModelDto.applyProperty = skillInitial.applyProperty; skillModelDto.releaseType = skillInitial.releaseType; skillModelDto.efx_name = skillInitial.efx_name; skillModelDto.aniname = skillInitial.aniname; skillDto.SkillModelDto = skillModelDto; return(skillDto); }
public Skill(SkillDTO input) { AttackAnimation = input.AttackAnimation; CastAnimation = input.CastAnimation; CastEffect = input.CastEffect; CastId = input.CastId; CastTime = input.CastTime; Class = input.Class; Cooldown = input.Cooldown; CPCost = input.CPCost; Duration = input.Duration; Effect = input.Effect; Element = input.Element; HitType = input.HitType; ItemVNum = input.ItemVNum; Level = input.Level; LevelMinimum = input.LevelMinimum; MinimumAdventurerLevel = input.MinimumAdventurerLevel; MinimumArcherLevel = input.MinimumArcherLevel; MinimumMagicianLevel = input.MinimumMagicianLevel; MinimumSwordmanLevel = input.MinimumSwordmanLevel; MpCost = input.MpCost; Name = input.Name; Price = input.Price; Range = input.Range; SkillType = input.SkillType; SkillVNum = input.SkillVNum; TargetRange = input.TargetRange; TargetType = input.TargetType; Type = input.Type; UpgradeSkill = input.UpgradeSkill; UpgradeType = input.UpgradeType; Combos = new List <ComboDTO>(); BCards = new List <BCard>(); }
public IActionResult LevelUp([FromBody] SkillDTO data) { // Setup var id = data.Id; var level = data.Level; var sd = data.SkillData.PowerData; var scs = new SkillCostStat(sd); if (level == 0) { level++; } sd.Level = level; sd.Tier = data.Tier; var su = data.SkillData.PowerUp; // su.CD = scs.CD; // su.Cost = scs.Cost; // su.Charges = scs.Charges; su.Level = level + 1; su.Tier = data.Tier; // Modify data.SkillData.PowerData = new DamageSkillStat(level == _MAX ? sd : su); var newUp = new DamageSkillStat(su.CalculateSkillPower(su.Level + 1).CalculateSkillCosts(su.Level + 1)); data.SkillData.PowerUp = level == _MAX ? sd : newUp; data.Level = level; return(Ok(data)); }
public ActionResult AddExperience(SkillDTO SkillDTO) { var Owner = db.Employees.Find(SkillDTO.Owner); if (SkillDTO.SkillID == 0) { ModelState.AddModelError("", "Please selete a skill."); SkillDTO.Type = "Please Choose..."; ViewBag.Type = new SelectList(db.Skills.GroupBy(x => x.Type).Select(s => s.Key)); return(View(SkillDTO)); } var Skill = db.Skills.Find(SkillDTO.SkillID); if (Owner.Skills.Contains(Skill)) { ModelState.AddModelError("", SkillDTO.Owner + " already has this skill."); ViewBag.Type = new SelectList(db.Skills.GroupBy(x => x.Type).Select(s => s.Key)); SkillDTO.Type = "Please Choose..."; return(View(SkillDTO)); } Owner.Skills.Add(Skill); EmployeeSkillDetail detail = new EmployeeSkillDetail(); detail.Comment = SkillDTO.Comment; detail.Date = Convert.ToDateTime(SkillDTO.Date); detail.Assessedby = SkillDTO.Assessedby; detail.Type = SkillDTO.Type; detail.Employee = SkillDTO.Owner; detail.Level = Skill.Level; detail.Skill = Skill.Name; db.EmployeeSkillDetails.Add(detail); db.SaveChanges(); return(RedirectToAction("Index", "Home")); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] SkillDTO skillDTO) { if (id != skillDTO.Id) { return(NotFound()); } try { var resp = await _skillService.UpdateSkill(skillDTO); if (resp != null) { return(RedirectToAction(nameof(Index))); } var updSkill = new Skill { Name = skillDTO.Name, XpCost = skillDTO.XpCost }; _skillRepository.UpdateSkill(updSkill); await _skillRepository.Save(); } catch (BrokenCircuitException) { HandleBrokenCircuit(); return(View()); } return(View(skillDTO)); }
public void Insert(SkillDTO entityDTO) { TSkill entity = Builders. GenericBuilder.builderDTOEntity <TSkill, SkillDTO> (entityDTO); repository.Save(entity); }
public void Update(SkillDTO entityDTO) { var entity = Builders. GenericBuilder.builderDTOEntity <TSkill, SkillDTO> (entityDTO); repository.Save(entity); }
public IActionResult Skill([FromBody] SkillModel model) { SkillDTO dto = Mapping.Mapper.Map <SkillModel, SkillDTO>(model); _curriculumService.AddOrUpdateSectionBlock <SkillDTO>(dto, model.FormMode, SectionNames.Skill); return(Ok(new { id = model.SkillId })); }
public IActionResult Post([FromBody] SkillDTO skill) { if (!ModelState.IsValid) { throw new Exception("Model is not Valid"); } Service.Insert(skill); return(Ok(true)); }
/// <summary> /// Convert SkillDTO to Skill model /// </summary> /// <param name="skillDTO"></param> /// <returns></returns> public static Skill ToModel(this SkillDTO skillDTO) { return(new Skill { SkillId = skillDTO.SkillId, SkillName = skillDTO.SkillName, SkillDescription = skillDTO.SkillDescription }); }
public static Skill DTOToSkill(SkillDTO skillDTO) => new Skill { ResumeId = skillDTO.ResumeId, Order = skillDTO.Order, Name = skillDTO.Name, Proficiency = skillDTO.Proficiency, Resume = null };
public static Skill ToEntity(this SkillDTO skillDTO) { return(new Skill { Id = skillDTO.Id, Name = skillDTO.Name, Scale = skillDTO.Scale }); }
public SkillDTO Create(SkillDTO modelDTO) { if (modelDTO != null) { return(SkillAssembler.ToDTO(SkillsRepo.Create(SkillAssembler.ToEntity(modelDTO)))); } return(null); }
public static Skill Map(SkillDTO skill) { return(new Skill { Id = skill.Id, Name = skill.Name, Category = skill.Category == null ? null : MapLazy(skill.Category) }); }
private static SkillViewModel Map(SkillDTO s) { return(new SkillViewModel { Id = s.Id, Name = s.Name, Category = s.Category == null ? null : Map(s.Category) }); }
public async void UpdateAsync(SkillDTO skillDTO) { if (await _context.Database.EnsureCreatedAsync()) { var skill = Mapper.Map <SkillDTO, Skill>(skillDTO); _context.Skills.Update(skill); await _context.SaveChangesAsync(); } }
public SkillDTO Insert(SkillDTO skill) { using (var context = DataAccessHelper.CreateContext()) { Skill entity = _mapper.Map <Skill>(skill); context.Skill.Add(entity); context.SaveChanges(); return(_mapper.Map <SkillDTO>(entity)); } }
public bool AddSkill(SkillDTO skillDTO) { var skill = Mapper.Map <Skills>(skillDTO); using (var unitOfWork = new UnitOfWork(new SkillsTrackerContext())) { unitOfWork.Skills.Add(skill); var result = unitOfWork.Complete(); return(result == 1); } }
public static SkillDTO Map(Skill sid) { SkillDTO result = new SkillDTO { Id = sid.Id, Name = sid.Name, Category = MapLazy(sid.Category) }; return(result); }