Beispiel #1
0
        public HttpResponseMessage Add([FromBody] Gepro.SaaS.Domain.Entities.Person.PersonType entity)
        {
            try
            {
                service.Add(entity);

                HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created);
                response.Headers.Location = new Uri(Url.Link("DefaultApi", new { controller = "PersonType", id = entity.Id }));

                return(response);
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message));
            }
        }
Beispiel #2
0
        public HttpResponseMessage Edit([FromBody] Gepro.SaaS.Domain.Entities.Person.PersonType entity)
        {
            try
            {
                var item = service.ListById(entity.Id);

                if (item == null)
                {
                    throw new KeyNotFoundException();
                }

                service.Update(entity);

                return(Request.CreateResponse(HttpStatusCode.OK));
            }
            catch (KeyNotFoundException)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Not found"));
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message));
            }
        }
Beispiel #3
0
 public void Update(Gepro.SaaS.Domain.Entities.Person.PersonType entity)
 {
     repository.Edit(entity);
 }
Beispiel #4
0
 public void Add(Gepro.SaaS.Domain.Entities.Person.PersonType entity)
 {
     repository.Add(entity);
 }