コード例 #1
0
        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());
            }
        }
コード例 #2
0
ファイル: SkillService.cs プロジェクト: monjurulrana/EasyHRM
        public SkillDTO InsertSkill(SkillDTO data)
        {
            Skill dataToInsert = new Skill();

            dataToInsert = SkillRequestFormatter.ConvertRespondentInfoFromDTO(data);
            return(SkillRequestFormatter.ConvertRespondentInfoToDTO(_unitOfWork.SkillRepository.Create(dataToInsert)));
        }
コード例 #3
0
        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));
            }
        }
コード例 #4
0
        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));
            }
        }
コード例 #5
0
ファイル: SkillDAO.cs プロジェクト: tolgatr61/nostormv2
        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);
            }
        }
コード例 #6
0
ファイル: SkillService.cs プロジェクト: monjurulrana/EasyHRM
        public int UpdateSkill(SkillDTO data)
        {
            Skill dataToUpdate = SkillRequestFormatter.ConvertRespondentInfoFromDTO(data);
            var   res          = _unitOfWork.SkillRepository.Update(dataToUpdate);

            return(res);
        }
コード例 #7
0
        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));
        }
コード例 #8
0
 public IActionResult Put(Guid SkillId,
                          [FromBody] SkillDTO skill)
 {
     skill.SkillId = SkillId;
     Service.Update(skill);
     return(Ok(true));
 }
コード例 #9
0
        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);
        }
コード例 #10
0
        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));
        }
コード例 #11
0
        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)));
        }
コード例 #12
0
ファイル: SkillBiz.cs プロジェクト: hehay/MyServer
        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);
        }
コード例 #13
0
 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>();
 }
コード例 #14
0
        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));
        }
コード例 #15
0
        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"));
        }
コード例 #16
0
        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));
        }
コード例 #17
0
ファイル: SkillService.cs プロジェクト: GaboAlex/CodiJob
        public void Insert(SkillDTO entityDTO)
        {
            TSkill entity = Builders.
                            GenericBuilder.builderDTOEntity <TSkill, SkillDTO>
                                (entityDTO);

            repository.Save(entity);
        }
コード例 #18
0
ファイル: SkillService.cs プロジェクト: GaboAlex/CodiJob
        public void Update(SkillDTO entityDTO)
        {
            var entity = Builders.
                         GenericBuilder.builderDTOEntity <TSkill, SkillDTO>
                             (entityDTO);

            repository.Save(entity);
        }
コード例 #19
0
        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 }));
        }
コード例 #20
0
ファイル: SkillController.cs プロジェクト: GaboAlex/CodiJob
 public IActionResult Post([FromBody] SkillDTO skill)
 {
     if (!ModelState.IsValid)
     {
         throw new Exception("Model is not Valid");
     }
     Service.Insert(skill);
     return(Ok(true));
 }
コード例 #21
0
ファイル: ModelExtension.cs プロジェクト: adichourasiya/skill
 /// <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
     });
 }
コード例 #22
0
 public static Skill DTOToSkill(SkillDTO skillDTO) =>
 new Skill
 {
     ResumeId    = skillDTO.ResumeId,
     Order       = skillDTO.Order,
     Name        = skillDTO.Name,
     Proficiency = skillDTO.Proficiency,
     Resume      = null
 };
コード例 #23
0
 public static Skill ToEntity(this SkillDTO skillDTO)
 {
     return(new Skill
     {
         Id = skillDTO.Id,
         Name = skillDTO.Name,
         Scale = skillDTO.Scale
     });
 }
コード例 #24
0
        public SkillDTO Create(SkillDTO modelDTO)
        {
            if (modelDTO != null)
            {
                return(SkillAssembler.ToDTO(SkillsRepo.Create(SkillAssembler.ToEntity(modelDTO))));
            }

            return(null);
        }
コード例 #25
0
 public static Skill Map(SkillDTO skill)
 {
     return(new Skill
     {
         Id = skill.Id,
         Name = skill.Name,
         Category = skill.Category == null ? null : MapLazy(skill.Category)
     });
 }
コード例 #26
0
 private static SkillViewModel Map(SkillDTO s)
 {
     return(new SkillViewModel
     {
         Id = s.Id,
         Name = s.Name,
         Category = s.Category == null ? null : Map(s.Category)
     });
 }
コード例 #27
0
 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();
     }
 }
コード例 #28
0
 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));
     }
 }
コード例 #29
0
ファイル: SkillsBAL.cs プロジェクト: nakash2050/SkillsTracker
        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);
            }
        }
コード例 #30
0
        public static SkillDTO Map(Skill sid)
        {
            SkillDTO result = new SkillDTO
            {
                Id       = sid.Id,
                Name     = sid.Name,
                Category = MapLazy(sid.Category)
            };

            return(result);
        }