예제 #1
0
        public ActionResult CustomerOrder(TRNCustomerOrderMetadata model)
        {
            try {
                if (ModelState.IsValid)
                {
                    TRNCustomerOrder o = new TRNCustomerOrder()
                    {
                        CustomerName     = model.CustomerName,
                        Contact          = model.Contact,
                        Email            = model.Email,
                        Address          = model.Address,
                        OrderDescription = model.OrderDescription,
                        preferredDate    = model.preferredDate,
                        preferredTimeID  = model.preferredTimeID,
                        FuelTypeId       = model.FuelTypeId,
                        UnitTypeId       = model.UnitTypeId,
                        ServiceTypeId    = model.ServiceTypeId,
                        CreateOn         = System.DateTime.Now,
                        OrderStatusId    = 6
                    };
                    string serviceType = db.STPServiceTypes.Find(model.ServiceTypeId).ServiceTypeName;


                    STPNotification n = new STPNotification
                    {
                        Message     = serviceType + " Order Placed",
                        Is_Notify   = false,
                        CreatedDate = DateTime.Now
                    };

                    db.TRNCustomerOrders.Add(o);
                    db.STPNotifications.Add(n);
                    db.SaveChanges();
                    TempData["Message"] = "success";

                    return(Redirect(Url.Action("Index", "Home")));
                }
                else
                {
                    TempData["Message"] = "error";
                    return(Redirect(Url.Action("Index", "Home")));
                }
            }
            catch {
                TempData["Message"] = "error";
                return(Redirect(Url.Action("Index", "Home")));
            }
        }
예제 #2
0
        public JsonResult NotificationSuccess()
        {
            try {
                var data = (from d in db.STPNotifications
                            where d.Is_Notify == false
                            select d).ToList();


                foreach (var item in data)
                {
                    STPNotification f = db.STPNotifications.FirstOrDefault(x => x.ID == item.ID);
                    f.Is_Notify = true;
                    db.SaveChanges();
                }

                return(Json(true, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                throw ex;
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
        }
예제 #3
0
        public ActionResult pvQuickCall(QuickCall q)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    STPQuickCall Qcall = new STPQuickCall()
                    {
                        Name    = q.Name,
                        Contact = q.Contact
                    };

                    STPNotification n = new STPNotification
                    {
                        Message     = q.Name + " Request a Call!",
                        Is_Notify   = false,
                        CreatedDate = DateTime.Now
                    };

                    db.STPNotifications.Add(n);
                    db.STPQuickCalls.Add(Qcall);
                    db.SaveChanges();
                    Session["Message"] = "QCallSucceed";
                    return(RedirectToAction("Index"));
                }
                catch
                {
                    Session["Message"] = "QCallFailed";
                }
            }
            else
            {
                Session["Message"] = "QCallFailed";
            }
            return(View());
        }