Пример #1
0
 private static void CreateNewRelocationPlaces(Candidate destination, CandidateDTO source, IRepository <City> locationRepo)
 {
     source.RelocationPlaces.Where(x => x.IsNew()).ToList().ForEach(newRelocationPlace =>
     {
         var toDomain = DTOService.ToEntity <RelocationPlaceDTO, RelocationPlace>(newRelocationPlace);
         destination.RelocationPlaces.Add(toDomain);
     });
 }
Пример #2
0
 public virtual IHttpActionResult Add([FromBody] ViewModel entity)
 {
     if (ModelState.IsValid)
     {
         var newEntity = DTOService.ToEntity <ViewModel, DomainEntity>(entity);
         _currentRepo.Add(newEntity);
         return(Json(DTOService.ToDTO <DomainEntity, ViewModel>(_currentRepo.GetAll().Last())));
     }
     return(BadRequest());
 }
Пример #3
0
 public virtual IHttpActionResult Put(int id, [FromBody] ViewModel changedEntity)
 {
     if (ModelState.IsValid)
     {
         if (changedEntity != null)
         {
             var changedDomainEntity = DTOService.ToEntity <ViewModel, DomainEntity>(changedEntity);
             _currentRepo.Update(changedDomainEntity);
             return(Json(DTOService.ToDTO <DomainEntity, ViewModel>(_currentRepo.Get(changedDomainEntity.Id)), SERIALIZER_SETTINGS));
         }
         return(NotFound());
     }
     return(BadRequest());
 }