コード例 #1
0
        public DoctorServiceDto Create(DoctorServiceDto doctorServiceDto, bool byAdmin)
        {
            if (doctorServiceDto == null)
            {
                throw new ArgumentNullException();
            }

            DoctorService doctorService = Mapper.Map <DoctorService>(doctorServiceDto);

            doctorService.ByAdmin = byAdmin;
            TheUnitOfWork.DoctorServiceRepo.Insert(doctorService);
            TheUnitOfWork.SaveChanges();
            doctorServiceDto.ID      = doctorService.ID;
            doctorServiceDto.ByAdmin = byAdmin;
            return(doctorServiceDto);
        }
コード例 #2
0
        public bool Update(DoctorServiceDto doctorServiceDto)
        {
            if (doctorServiceDto == null)
            {
                throw new ArgumentNullException();
            }

            bool result = false;

            doctorServiceDto.ByAdmin = true;
            DoctorService doctorService = Mapper.Map <DoctorService>(doctorServiceDto);

            TheUnitOfWork.DoctorServiceRepo.Update(doctorService);
            result = TheUnitOfWork.SaveChanges() > new int();
            return(result);
        }
コード例 #3
0
        public IActionResult Create(DoctorServiceDto doctorServiceDto)
        {
            if (ModelState.IsValid == false)
            {
                return(BadRequest(ModelState));
            }

            if (_doctorServiceAppService.CheckExistsByName(doctorServiceDto.Name))
            {
                return(BadRequest(new Response {
                    Message = "This Name Alreay Exist"
                }));
            }


            try
            {
                string userRole = HttpContext.User.FindFirst(ClaimTypes.Role).Value;
                if (userRole == UserRoles.Admin)
                {
                    doctorServiceDto = _doctorServiceAppService.Create(doctorServiceDto, true);
                }
                else
                {
                    doctorServiceDto = _doctorServiceAppService.Create(doctorServiceDto, false);
                }

                _generalAppService.CommitTransaction();
                return(Created("Area created", doctorServiceDto));
            }
            catch (Exception ex)
            {
                _generalAppService.RollbackTransaction();
                return(BadRequest(new Response {
                    Message = ex.Message
                }));
            }
        }
コード例 #4
0
        public IActionResult Update(DoctorServiceDto doctorServiceDto)
        {
            if (ModelState.IsValid == false)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                _doctorServiceAppService.Update(doctorServiceDto);
                _generalAppService.CommitTransaction();
                return(Ok(new Response {
                    Message = "Updated Successfully"
                }));
            }
            catch (Exception ex)
            {
                _generalAppService.RollbackTransaction();
                return(BadRequest(new Response {
                    Message = ex.Message
                }));
            }
        }