Пример #1
0
        public LaboratoryModel Map(LaboratoryAPIModel laboratoryAPIModel)
        {
            if (laboratoryAPIModel == null)
            {
                return(null);
            }

            return(new LaboratoryModel
            {
                LabNumber = laboratoryAPIModel.LabNumber,
                Date = laboratoryAPIModel.Date,
                Title = laboratoryAPIModel.Title,
                Curricula = laboratoryAPIModel.Curricula,
                Description = laboratoryAPIModel.Description
            });
        }
Пример #2
0
        public HttpResponseMessage Update([FromBody] LaboratoryAPIModel laboratoryAPIModel)
        {
            if (laboratoryAPIModel == null)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }

            if (_laboratoryService.CheckIfLaboratoryExists(laboratoryAPIModel.LabNumber) == true)
            {
                _laboratoryService.UpdateLaboratory(_laboratoryAPIMapper.Map(laboratoryAPIModel));
                return(Request.CreateResponse(HttpStatusCode.Created, _laboratoryAPIMapper.Map(laboratoryAPIModel)));
            }
            else
            {
                return(Request.CreateErrorResponse(HttpStatusCode.Conflict, "Laboratory not added yet!"));
            }
        }
Пример #3
0
        public HttpResponseMessage Create([FromBody] LaboratoryAPIModel laboratoryAPIModel)
        {
            if (_laboratoryService.GetByLabNumber(_laboratoryAPIMapper.Map(laboratoryAPIModel).LabNumber) != null)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.Conflict, "Laboratory already created!"));
            }

            else
            if (laboratoryAPIModel == null)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }
            else
            {
                _laboratoryService.AddLaboratory(_laboratoryAPIMapper.Map(laboratoryAPIModel));
                return(Request.CreateResponse(HttpStatusCode.Created, _laboratoryAPIMapper.Map(laboratoryAPIModel)));
            }
        }