Exemple #1
0
 public HttpResponseMessage SubscribeService(SERVICEORDER orp)
 {
     try
     {
         var orderservice = new OrderService();
         orp.Orderdate = DateTime.Now;
         var id       = orderservice.AddServiceInOrder(orp);
         var response = Request.CreateResponse(HttpStatusCode.OK, id);
         return(response);
     }
     catch (Exception e)
     {
         var error = Request.CreateResponse(HttpStatusCode.InternalServerError, e.Message);
         return(error);
     }
 }
Exemple #2
0
        /// <summary>
        /// Add new product to Cart
        /// </summary>
        /// <param name="product"></param>
        /// <returns></returns>
        public Guid AddServiceInOrder(SERVICEORDER product)
        {
            try
            {
                if (product == null)
                {
                    throw new ArgumentNullException("Service", "Service can not be null");
                }

                // check if all required fields are present
                if ((product.SERVICEID == null || product.SERVICEID == Guid.Empty) ||
                    (product.BUYERID == null || product.BUYERID == Guid.Empty))
                {
                    throw new ArgumentException("Some mandatory parameters required to add a new product are missing", "Product");
                }
                try
                {
                    using (APIShopKaro.Models.apsteamCFHEntities db = new APIShopKaro.Models.apsteamCFHEntities())
                    {
                        try
                        {
                            db.SERVICEORDERs.Add(product);
                            db.SaveChanges();
                        }
                        catch (System.Data.DataException e)
                        {
                            throw new Exception(e.InnerException.InnerException.Message);
                        }
                    }
                    return(product.SERVICEID);
                }
                catch (Exception e)
                {
                    throw new Exception(e.InnerException.InnerException.Message);
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.InnerException.InnerException.Message);
            }
        }