Esempio n. 1
0
        public void Post_UpdateContact([FromBody] Models.Contact mContact)
        {
            IContactBS bs = DIFactoryDesigntime.GetInstance <IContactBS>();
            IBaseConverter <Models.Contact, Entities.Contact> convtResult = new AutoMapConverter <Models.Contact, Entities.Contact>();

            Entities.Contact eContact = convtResult.ConvertObject(mContact);
            bs.UpdateContact(eContact);
        }
        public async Task <ResponseDataViewModel> DeleteContact([FromBody] List <int> ids)
        {
            _logger.LogInformation($"Delete contact list from method UpdateContact() { ids.Count}");
            var result = await _contactServiceAgent.DeleteContact(ids);

            _logger.LogInformation("Delete contact list from method UpdateContact() successful");
            return(AutoMapConverter.ConvertObject <ResponseData, ResponseDataViewModel>(result));
        }
        public async Task <ContactViewModel> GetContactById(int id)
        {
            _logger.LogInformation($"Get contact list from method GetContactById() with id : { id }");
            var eContact = await _contactServiceAgent.GetContactById(id);

            _logger.LogInformation("Get contact list from method GetContactById() successful");
            return(AutoMapConverter.ConvertObject <Contact, ContactViewModel>(eContact));
        }
        public async Task <ResponseDataViewModel> UpdateContact([FromBody] List <ContactViewModel> mContact)
        {
            _logger.LogInformation("Update contact list from method UpdateContact()");
            var eContact = AutoMapConverter.ConvertObjectCollection <ContactViewModel, Contact>(mContact);
            var result   = await _contactServiceAgent.UpdateContact(eContact);

            _logger.LogInformation("Update contact list from method UpdateContact() Successful");
            return(AutoMapConverter.ConvertObject <ResponseData, ResponseDataViewModel> (result));
        }
 public AddContactResponse Post_AddContact([FromBody] Models.Contact mContact)
 {
     IContactBS bs = DIFactoryDesigntime.GetInstance<IContactBS>();
     IBaseConverter<Models.Contact, Entities.Contact> convtResult = new AutoMapConverter<Models.Contact, Entities.Contact>();
     Entities.Contact eContact = convtResult.ConvertObject(mContact);
     bs.AddContact(eContact);
     
     var addContactResponse = new AddContactResponse() 
     {
         ContactID =  eContact.ContactID
     };
     return addContactResponse; 
 }
Esempio n. 6
0
        public AddContactResponse Post_AddContact([FromBody] Models.Contact mContact)
        {
            IContactBS bs = DIFactoryDesigntime.GetInstance <IContactBS>();
            IBaseConverter <Models.Contact, Entities.Contact> convtResult = new AutoMapConverter <Models.Contact, Entities.Contact>();

            Entities.Contact eContact = convtResult.ConvertObject(mContact);
            bs.AddContact(eContact);

            var addContactResponse = new AddContactResponse()
            {
                ContactID = eContact.ContactID
            };

            return(addContactResponse);
        }
 public AddContactsResponse Post_AddContacts([FromBody] List<Models.Contact> mContactList)
 {
     var contactIdList = new List<int>();
     IContactBS bs = DIFactoryDesigntime.GetInstance<IContactBS>();
     foreach (var mContact in mContactList)
     {
         IBaseConverter<Models.Contact, Entities.Contact> convtResult = new AutoMapConverter<Models.Contact, Entities.Contact>();
         Entities.Contact eContact = convtResult.ConvertObject(mContact);
         bs.AddContact(eContact);
         contactIdList.Add(eContact.ContactID);                
     }
     var resp = new AddContactsResponse();
     resp.ContactIdList = contactIdList;
     return resp;
 }
 public IHttpActionResult GetContactById(int id)
 {
     IContactBS bs = DIFactoryDesigntime.GetInstance<IContactBS>();
     var eContact = bs.GetContactById(id);
     if (eContact == null)
     {
         return NotFound();
     }
     else
     {
         IBaseConverter<Entities.Contact, Models.Contact> convtResult = new AutoMapConverter<Entities.Contact, Models.Contact>();
         Models.Contact mContact = convtResult.ConvertObject(eContact);
         return Ok(mContact);
     }
 }
Esempio n. 9
0
        public IHttpActionResult GetContactById(int id)
        {
            IContactBS bs       = DIFactoryDesigntime.GetInstance <IContactBS>();
            var        eContact = bs.GetContactById(id);

            if (eContact == null)
            {
                return(NotFound());
            }
            else
            {
                IBaseConverter <Entities.Contact, Models.Contact> convtResult = new AutoMapConverter <Entities.Contact, Models.Contact>();
                Models.Contact mContact = convtResult.ConvertObject(eContact);
                return(Ok(mContact));
            }
        }
Esempio n. 10
0
        public HttpResponseMessage Post_AddProduct([FromBody] Models.Product mProduct)
        {
            IProductBS bs = DIFactoryDesigntime.GetInstance <IProductBS>();
            IBaseConverter <Models.Product, Entities.Product> convtResult = new AutoMapConverter <Models.Product, Entities.Product>();

            Entities.Product eProduct = convtResult.ConvertObject(mProduct);
            bs.AddProduct(eProduct);

            var response = Request.CreateResponse(HttpStatusCode.Created);

            // Generate a link to the new product and set the Location header in the response.
            string uri = Url.Link("GetProductById", new { id = eProduct.ProductID });

            response.Headers.Location = new Uri(uri);
            return(response);
        }
Esempio n. 11
0
        public AddContactsResponse Post_AddContacts([FromBody] List <Models.Contact> mContactList)
        {
            var        contactIdList = new List <int>();
            IContactBS bs            = DIFactoryDesigntime.GetInstance <IContactBS>();

            foreach (var mContact in mContactList)
            {
                IBaseConverter <Models.Contact, Entities.Contact> convtResult = new AutoMapConverter <Models.Contact, Entities.Contact>();
                Entities.Contact eContact = convtResult.ConvertObject(mContact);
                bs.AddContact(eContact);
                contactIdList.Add(eContact.ContactID);
            }
            var resp = new AddContactsResponse();

            resp.ContactIdList = contactIdList;
            return(resp);
        }
 public void Post_UpdateContacts([FromBody] List<Models.Contact> mContactList)
 {
     IContactBS bs = DIFactoryDesigntime.GetInstance<IContactBS>();
     foreach (var mContact in mContactList)
     {
         IBaseConverter<Models.Contact, Entities.Contact> convtResult = new AutoMapConverter<Models.Contact, Entities.Contact>();
         Entities.Contact eContact = convtResult.ConvertObject(mContact);
         bs.UpdateContact(eContact);
     }            
 }
 public void Post_UpdateProduct([FromBody] Models.Product mProduct)
 {
     IProductBS bs = DIFactoryDesigntime.GetInstance<IProductBS>();
     IBaseConverter<Models.Product, Entities.Product> convtResult = new AutoMapConverter<Models.Product, Entities.Product>();
     Entities.Product eProduct = convtResult.ConvertObject(mProduct);
     bs.UpdateProduct(eProduct);
 }
        public AddProductResponse Post_AddProduct([FromBody] Models.Product mProduct)
        {
            IProductBS bs = DIFactoryDesigntime.GetInstance<IProductBS>();
            IBaseConverter<Models.Product, Entities.Product> convtResult = new AutoMapConverter<Models.Product, Entities.Product>();
            Entities.Product eProduct = convtResult.ConvertObject(mProduct);
            bs.AddProduct(eProduct);
            
            var addProductResponse = new AddProductResponse() 
            {
                ProductID =  eProduct.ProductID
            };
            return addProductResponse;  

            ////Generate a link to the new product and set the Location header in the response.
            ////For public HttpResponseMessage Post_AddProduct([FromBody] Models.Product mProduct)
            //var response = Request.CreateResponse(HttpStatusCode.Created);            
            //string uri = Url.Link("GetProductById", new { id = eProduct.ProductID });
            //response.Headers.Location = new Uri(uri);
            //return response;
        }