Example #1
0
 public void SaveCustomer(CustomerViewModel model)
 {
     Mapper.CreateMap<CustomerViewModel, Customer>();
     var cust = Mapper.Map<CustomerViewModel, Customer>(model);
     db.Update(cust);
 }
        // POST api/customers
        public HttpResponseMessage Post(CustomerViewModel model)
        {
            try
            {
                service.AddCustomer(model);
                return Request.CreateResponse(HttpStatusCode.OK);
            }
            catch (Exception ex)
            {
                return Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message.ToString());

            }
        }
Example #3
0
 public void AddCustomer(CustomerViewModel model)
 {
     Mapper.CreateMap<CustomerViewModel, Customer>();
     var cust = Mapper.Map<CustomerViewModel, Customer>(model);
     db.Insert(cust);
 }