Exemplo n.º 1
0
        public IActionResult Post(DoctorAttachmentDto doctorDto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            try
            {
                var user = _httpContextAccessor.HttpContext.User.Claims;


                var userID = _httpContextAccessor.HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value;
                doctorDto.DoctorId = userID; //"625a57bf-8c7d-4f34-b98f-92df9f2f86ad";    //change after login story
                DoctorAttachmentDto doctor = _doctorAttachmentAppService.Insert(doctorDto);
                _generalAppService.CommitTransaction();
                return(Created("attachment send", doctorDto));
            }
            catch (Exception ex)
            {
                _generalAppService.RollbackTransaction();
                return(BadRequest(new Response()
                {
                    Message = ex.Message
                }));
            }
        }
Exemplo n.º 2
0
        public bool Update(DoctorAttachmentDto attachmentDto)
        {
            if (attachmentDto == null)
            {
                throw new ArgumentNullException();
            }
            bool             result           = false;
            DoctorAttachment doctorAttachment = Mapper.Map <DoctorAttachment>(attachmentDto);

            doctorAttachment.isBinding = true;
            TheUnitOfWork.DoctorAttachmentRepo.Update(doctorAttachment);
            result = TheUnitOfWork.SaveChanges() > new int();
            return(result);
        }
Exemplo n.º 3
0
        public DoctorAttachmentDto Insert(DoctorAttachmentDto doctorDto)
        {
            if (doctorDto == null)
            {
                throw new ArgumentNullException();
            }
            DoctorAttachment doctor = Mapper.Map <DoctorAttachment>(doctorDto);

            doctor.isBinding = true;
            TheUnitOfWork.DoctorAttachmentRepo.Insert(doctor);
            TheUnitOfWork.SaveChanges();
            doctorDto.DoctorId = doctor.DoctorId;
            return(doctorDto);
        }
Exemplo n.º 4
0
 public IActionResult Put(DoctorAttachmentDto attachmentDto)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest(ModelState));
     }
     try
     {
         _doctorAttachmentAppService.Update(attachmentDto);
         _generalAppService.CommitTransaction();
         return(Ok(new Response {
             Message = "attachment are updated"
         }));
     }
     catch (Exception ex)
     {
         _generalAppService.RollbackTransaction();
         return(BadRequest(new Response {
             Message = ex.Message
         }));
     }
 }