示例#1
0
        // POST: api/Services/serviceDtm
        public async Task <HttpResponseMessage> Post([FromBody] ServiceDTM serviceDtm)
        {
            try
            {
                int id = await TheRepo.ServicesDTM.Create(serviceDtm);

                return(Request.CreateResponse(HttpStatusCode.Created, id));
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
            }
        }
示例#2
0
        public static ServiceDTM changeToDTM(Service service)
        {
            ServiceDTM serviceDtm = new ServiceDTM();

            serviceDtm.Id           = service.Id;
            serviceDtm.Name         = service.Name;
            serviceDtm.Description  = service.Description;
            serviceDtm.Price        = service.Price;
            serviceDtm.Duration     = service.Duration;
            serviceDtm.PaddingAfter = service.PaddingAfter;
            serviceDtm.Picture      = service.Picture;

            serviceDtm.ServiceCategory = service.ServiceCategory == null ? null : changeToDTM(service.ServiceCategory);

            return(serviceDtm);
        }
示例#3
0
        public async Task <HttpResponseMessage> Put([FromBody] ServiceDTM serviceDtm)
        {
            try
            {
                var originalService = TheRepo.ServicesDTM.Get(serviceDtm.Id);

                if (originalService == null)
                {
                    return(Request.CreateResponse(HttpStatusCode.NotModified, "Item is not found"));
                }
                else
                {
                    await TheRepo.ServicesDTM.Update(serviceDtm);

                    return(Request.CreateResponse(HttpStatusCode.OK, serviceDtm));
                }
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
            }
        }