Esempio n. 1
0
        public void UpdateSalesJobMasterListCustomerID(int jcID)
        {
            var jc = _db.Sales_JobMasterList_Customer.Find(jcID);

            PostBackProjectID = jc.jobID;

            jc.cID = RowID;

            _db.Entry(jc).State = EntityState.Modified;
            _db.SaveChanges();
        }
        public IHttpActionResult PutOrder(int id, Order order)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != order.OrderId)
            {
                return(BadRequest());
            }

            db.Entry(order).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!OrderExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Esempio n. 3
0
        public IHttpActionResult PutRestaurant(int id, Restaurant restaurant)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != restaurant.ResId)
            {
                return(BadRequest());
            }

            db.Entry(restaurant).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!RestaurantExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public IHttpActionResult PutAdmin_Table(int id, Admin_Table admin_Table)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != admin_Table.AminId)
            {
                return(BadRequest());
            }

            db.Entry(admin_Table).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!Admin_TableExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Esempio n. 5
0
        /// <summary>
        /// Edit an existing lead
        /// </summary>
        /// <param name="createViewModel"></param>
        /// <param name="username"></param>
        public void EditLead(LeadModifyViewMode createViewModel, string username)
        {
            var lead = createViewModel.Lead;
            var emp  = new CrmEmployee(username);

            lead.LastUpdatedBy = emp.UserEmployeeID;

            lead.LastUpdatedAt = DateTime.Now;
            var cdt = lead.CriticalDeadline;

            lead.CriticalDeadline = cdt;

            try
            {
                _db.Entry(lead).State = EntityState.Modified;

                createViewModel.Address.AddressID        = lead.AddressID;
                _db.Entry(createViewModel.Address).State = EntityState.Modified;

                _db.SaveChanges();

                RecordLeadStatusChangdTime(lead);
                RecordLeadAeChangdTime(lead);
                LogMethods.Log.Debug("EditLead:Debug:" + "Done");
            }
            catch (Exception ex)
            {
                LogMethods.Log.Error("EditLead:Error:" + ex.Message);
            }
        }
Esempio n. 6
0
 //update customer
 public HttpResponseMessage Put(int id, Customer customer)
 {
     if (!ModelState.IsValid)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
     }
     if (id != customer.CustomerID)
     {
         return(Request.CreateResponse(HttpStatusCode.BadRequest));
     }
     db.Entry(customer).State = EntityState.Modified;
     try
     {
         db.SaveChanges();
     }
     catch (DbUpdateConcurrencyException ex)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.NotFound, ex));
     }
     return(Request.CreateResponse(HttpStatusCode.OK));
 }
Esempio n. 7
0
        private void UpdateSales_JobMasterList_Customer(int jcID, int jobID, int contactID, int customerID, int type)
        {
            try
            {
                var sales_JobMasterList_Customers = _db.Sales_JobMasterList_Customer.Where(x => x.jobID == jobID).ToList();
                if (sales_JobMasterList_Customers.Any())
                {
                    foreach (var element in sales_JobMasterList_Customers)
                    {
                        switch (type)
                        {
                        case 1:
                            element.isBillTo = false;
                            break;

                        case 2:
                            element.isQuoteTo = false;
                            break;

                        case 3:
                            element.isInstallOrShipTo = false;
                            break;

                        default:
                            break;
                        }
                        _db.Entry(element).State = EntityState.Modified;
                    }
                    _db.SaveChanges();
                }

                Sales_JobMasterList_Customer sales_JobMasterList_Customer = _db.Sales_JobMasterList_Customer.FirstOrDefault(x => x.jcID == jcID);
                if (sales_JobMasterList_Customer != null)
                {
                    switch (type)
                    {
                    case 1:
                        sales_JobMasterList_Customer.isBillTo = true;
                        break;

                    case 2:
                        sales_JobMasterList_Customer.isQuoteTo = true;
                        break;

                    case 3:
                        sales_JobMasterList_Customer.isInstallOrShipTo = true;
                        break;

                    default:
                        break;
                    }
                    sales_JobMasterList_Customer.contactName      = contactID;
                    sales_JobMasterList_Customer.cID              = customerID;
                    _db.Entry(sales_JobMasterList_Customer).State = EntityState.Modified;
                    _db.SaveChanges();
                }

                LogMethods.Log.Debug("UpdateSales_JobMasterList_Customer:Debug:" + "Done");
            }
            catch (Exception e)
            {
                LogMethods.Log.Error("UpdateSales_JobMasterList_Customer:Error:" + e.Message);
            }
        }