public ApiProducer Add(ApiProducer apiProducer) { db.Producers.Add(Mapper.Map <ApiProducer, Producer>(apiProducer)); apiProducer.ProducerID = db.SaveChanges(); return(apiProducer); }
public ApiProducer Post([FromBody] ApiProducer apiProducer) { try { apiProducer = service.Add(apiProducer); } catch (Exception ex) { throw ex; } return(apiProducer); }
public ApiProducer Put([FromBody] ApiProducer apiProducer) { try { int?id = apiProducer.ProducerID; apiProducer = service.Update(id, apiProducer); } catch (Exception ex) { throw ex; } return(apiProducer); }
public ApiProducer GetSingle(int?id) { ApiProducer apiProducer = new ApiProducer(); try { apiProducer = service.GetSingle(id); } catch (Exception ex) { throw ex; } return(apiProducer); }
public ApiProducer Update(int?id, ApiProducer apiProducer) { var producerInDB = db.Producers.Where(p => p.ProducerID == id).FirstOrDefault(); if (producerInDB != null) { apiProducer.ProducerID = producerInDB.ProducerID; producerInDB = Mapper.Map <ApiProducer, Producer>(apiProducer); db.Entry(producerInDB).State = System.Data.EntityState.Modified; db.SaveChanges(); } return(apiProducer); }
public ApiProducer Update(int?id, ApiProducer producer) { return(factory.ProducersDAO.Update(id, producer)); }
public ApiProducer Add(ApiProducer producer) { return(factory.ProducersDAO.Add(producer)); }