示例#1
0
 public async Task <IActionResult> UpdateTreatmentWay(TreatmentWayDto update)
 {
     if (await _treatmentWayService.Update(update))
     {
         return(NoContent());
     }
     return(BadRequest($"Updating Treatment Way {update.ID} failed on save"));
 }
示例#2
0
        public async Task <bool> Add(TreatmentWayDto model)
        {
            var treatmentWay = _mapper.Map <TreatmentWay>(model);
            var processID    = _repoProcess.FindAll().FirstOrDefault(x => x.Name == model.process).ID;

            treatmentWay.processID = processID;
            _repoTreatmentWay.Add(treatmentWay);
            return(await _repoTreatmentWay.SaveAll());
        }
示例#3
0
        public async Task <bool> Update(TreatmentWayDto model)
        {
            // string token = _accessor.HttpContext.Request.Headers["Authorization"];
            // var userID = JWTExtensions.GetDecodeTokenByProperty(token, "nameid").ToInt();
            // if (userID == 0) return false;
            var treatmentWay = _mapper.Map <TreatmentWay>(model);
            var processID    = _repoProcess.FindAll().FirstOrDefault(x => x.Name == model.process).ID;

            treatmentWay.processID = processID;
            _repoTreatmentWay.Update(treatmentWay);
            return(await _repoTreatmentWay.SaveAll());
        }
示例#4
0
        public async Task <IActionResult> CreateTreatmentWay(TreatmentWayDto create)
        {
            if (_treatmentWayService.GetById(create.ID) != null)
            {
                return(BadRequest("Treatment ID already exists!"));
            }
            //create.CreatedDate = DateTime.Now;
            if (await _treatmentWayService.Add(create))
            {
                return(NoContent());
            }

            throw new Exception("Creating the Treatment failed on save");
        }