Beispiel #1
0
 public static void FillDto(Models.PersonCertification entity, ViewModels.PersonCertificationDto personcertification)
 {
     personcertification.Id        = entity.Id;
     personcertification.Title     = entity.Title;
     personcertification.Authority = entity.Authority;
     personcertification.Remark    = entity.Remark;
     personcertification.PersonId  = entity.PersonId;
 }
Beispiel #2
0
 public static void Fill(Models.PersonCertification entity, ViewModels.PersonCertificationDto personcertification)
 {
     entity.Id        = personcertification.Id;
     entity.Title     = personcertification.Title;
     entity.Authority = personcertification.Authority;
     entity.Remark    = personcertification.Remark;
     entity.PersonId  = personcertification.PersonId;
 }
Beispiel #3
0
        public async Task <IHttpActionResult> PostUserCertification(ViewModels.PersonCertificationDto dto)
        {
            // return Ok(client);
            if (dto == null)
            {
                return(Exceptions.getNullException(ModelState));
            }
            if (!ModelState.IsValid)
            {
                // return BadRequest(ModelState);
                return(Exceptions.getModelValidationException(ModelState));
            }
            // var validate = unitOfWork.PersonMiscRepository.Validate(dto);
            // if (validate.Code != HttpStatusCode.OK)
            //      return validate;

            PersonCertification entity = null;

            if (dto.Id == -1)
            {
                entity = new PersonCertification();
                unitOfWork.PersonRepository.Insert(entity);
            }

            else
            {
                entity = await unitOfWork.PersonRepository.GetCertificationByID(dto.Id);
            }

            if (entity == null)
            {
                return(Exceptions.getNotFoundException());
            }

            //ViewModels.Location.Fill(entity, dto);
            ViewModels.PersonCertificationDto.Fill(entity, dto);



            var saveResult = await unitOfWork.SaveAsync();

            if (saveResult.Code != HttpStatusCode.OK)
            {
                return(saveResult);
            }

            dto.Id = entity.Id;
            return(Ok(dto));
        }
Beispiel #4
0
        public async Task <IHttpActionResult> DeleteUserCertification(ViewModels.PersonCertificationDto dto)
        {
            var entity = await unitOfWork.PersonRepository.GetCertificationByID(dto.Id);

            if (entity == null)
            {
                return(NotFound());
            }
            //var canDelete = unitOfWork.PersonRepository.CanDelete(entity);
            //if (canDelete.Code != HttpStatusCode.OK)
            //    return canDelete;

            unitOfWork.PersonRepository.Delete(entity);

            var saveResult = await unitOfWork.SaveAsync();

            if (saveResult.Code != HttpStatusCode.OK)
            {
                return(saveResult);
            }

            return(Ok(dto));
        }