public virtual BOTeacherSkill MapEFToBO( TeacherSkill ef) { var bo = new BOTeacherSkill(); bo.SetProperties( ef.Id, ef.Name); return(bo); }
public virtual TeacherSkill MapBOToEF( BOTeacherSkill bo) { TeacherSkill efTeacherSkill = new TeacherSkill(); efTeacherSkill.SetProperties( bo.Id, bo.Name); return(efTeacherSkill); }
public void MapModelToEntity() { var mapper = new DALTeacherSkillMapper(); ApiTeacherSkillServerRequestModel model = new ApiTeacherSkillServerRequestModel(); model.SetProperties("A"); TeacherSkill response = mapper.MapModelToEntity(1, model); response.Name.Should().Be("A"); }
public virtual ApiTeacherSkillServerResponseModel MapEntityToModel( TeacherSkill item) { var model = new ApiTeacherSkillServerResponseModel(); model.SetProperties(item.Id, item.Name); return(model); }
public void MapEntityToModel() { var mapper = new DALTeacherSkillMapper(); TeacherSkill item = new TeacherSkill(); item.SetProperties(1, "A"); ApiTeacherSkillServerResponseModel response = mapper.MapEntityToModel(item); response.Id.Should().Be(1); response.Name.Should().Be("A"); }
public ActionResult Update(TeacherSkill ts) { if (ModelState.IsValid) { db.Entry(ts).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Teachers = db.Teachers.ToList(); ViewBag.Skills = db.Skills.ToList(); return(View(ts)); }
public virtual TeacherSkill MapModelToEntity( int id, ApiTeacherSkillServerRequestModel model ) { TeacherSkill item = new TeacherSkill(); item.SetProperties( id, model.Name); return(item); }
public void MapBOToEF() { var mapper = new DALTeacherSkillMapper(); var bo = new BOTeacherSkill(); bo.SetProperties(1, "A"); TeacherSkill response = mapper.MapBOToEF(bo); response.Id.Should().Be(1); response.Name.Should().Be("A"); }
public void MapEFToBO() { var mapper = new DALTeacherSkillMapper(); TeacherSkill entity = new TeacherSkill(); entity.SetProperties(1, "A"); BOTeacherSkill response = mapper.MapEFToBO(entity); response.Id.Should().Be(1); response.Name.Should().Be("A"); }
public ActionResult Create(TeacherSkill ts) { if (ModelState.IsValid) { db.TeacherSkills.Add(ts); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Teachers = db.Teachers.ToList(); ViewBag.Skills = db.Skills.ToList(); return(View(ts)); }
public virtual async Task <ApiTeacherSkillServerResponseModel> Get(int id) { TeacherSkill record = await this.TeacherSkillRepository.Get(id); if (record == null) { return(null); } else { return(this.DalTeacherSkillMapper.MapEntityToModel(record)); } }
public ActionResult Update(int id) { TeacherSkill ts = db.TeacherSkills.Find(id); if (ts == null) { return(HttpNotFound()); } ViewBag.Teachers = db.Teachers.ToList(); ViewBag.Skills = db.Skills.ToList(); return(View(ts)); }
public void MapEntityToModelList() { var mapper = new DALTeacherSkillMapper(); TeacherSkill item = new TeacherSkill(); item.SetProperties(1, "A"); List <ApiTeacherSkillServerResponseModel> response = mapper.MapEntityToModel(new List <TeacherSkill>() { { item } }); response.Count.Should().Be(1); }
public void MapEFToBOList() { var mapper = new DALTeacherSkillMapper(); TeacherSkill entity = new TeacherSkill(); entity.SetProperties(1, "A"); List <BOTeacherSkill> response = mapper.MapEFToBO(new List <TeacherSkill>() { entity }); response.Count.Should().Be(1); }
public ActionResult Delete(int id) { TeacherSkill ts = db.TeacherSkills.Find(id); if (ts == null) { return(HttpNotFound()); } db.TeacherSkills.Remove(ts); db.SaveChanges(); return(RedirectToAction("Index")); }
public async Task <IActionResult> Edit([FromBody] TeacherSkill item) { var teacher = await dbContext.TeacherSkill.AsNoTracking().FirstOrDefaultAsync(i => i.TeacherId == item.TeacherId); if (teacher != null) { await Task.Run(() => dbContext.TeacherSkill.Update(item)); await Task.Run(() => dbContext.SaveChanges()); return(Ok()); } return(BadRequest(new { message = "Can't edit teacher skill" })); }
public virtual async Task <CreateResponse <ApiTeacherSkillServerResponseModel> > Create( ApiTeacherSkillServerRequestModel model) { CreateResponse <ApiTeacherSkillServerResponseModel> response = ValidationResponseFactory <ApiTeacherSkillServerResponseModel> .CreateResponse(await this.TeacherSkillModelValidator.ValidateCreateAsync(model)); if (response.Success) { TeacherSkill record = this.DalTeacherSkillMapper.MapModelToEntity(default(int), model); record = await this.TeacherSkillRepository.Create(record); response.SetRecord(this.DalTeacherSkillMapper.MapEntityToModel(record)); await this.mediator.Publish(new TeacherSkillCreatedNotification(response.Record)); } return(response); }
public async void Get() { var mock = new ServiceMockFacade <ITeacherSkillRepository>(); var record = new TeacherSkill(); mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(record)); var service = new TeacherSkillService(mock.LoggerMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.TeacherSkillModelValidatorMock.Object, mock.BOLMapperMockFactory.BOLTeacherSkillMapperMock, mock.DALMapperMockFactory.DALTeacherSkillMapperMock, mock.BOLMapperMockFactory.BOLRateMapperMock, mock.DALMapperMockFactory.DALRateMapperMock); ApiTeacherSkillResponseModel response = await service.Get(default(int)); response.Should().NotBeNull(); mock.RepositoryMock.Verify(x => x.Get(It.IsAny <int>())); }
public virtual async Task <UpdateResponse <ApiTeacherSkillServerResponseModel> > Update( int id, ApiTeacherSkillServerRequestModel model) { var validationResult = await this.TeacherSkillModelValidator.ValidateUpdateAsync(id, model); if (validationResult.IsValid) { TeacherSkill record = this.DalTeacherSkillMapper.MapModelToEntity(id, model); await this.TeacherSkillRepository.Update(record); record = await this.TeacherSkillRepository.Get(id); ApiTeacherSkillServerResponseModel apiModel = this.DalTeacherSkillMapper.MapEntityToModel(record); await this.mediator.Publish(new TeacherSkillUpdatedNotification(apiModel)); return(ValidationResponseFactory <ApiTeacherSkillServerResponseModel> .UpdateResponse(apiModel)); } else { return(ValidationResponseFactory <ApiTeacherSkillServerResponseModel> .UpdateResponse(validationResult)); } }