Exemple #1
0
        public string Create(CustomerPopupModel model)
        {
            try
            {
                TravelaEntities db       = new TravelaEntities();
                CustomerT       customer = null;
                if (model.customerid > 0)
                {
                    customer = db.CustomerT.FirstOrDefault(f => f.customerid == model.customerid);
                }
                else
                {
                    customer = new CustomerT();
                }

                customer.customername    = model.customername;
                customer.customersurname = model.customersurname;
                customer.birthdate       = model.birthdate;
                customer.phone           = model.phone;
                customer.email           = model.email;
                customer.address         = model.address;

                if (model.customerid == 0)
                {
                    db.CustomerT.Add(customer);
                }

                return(db.SaveChanges().ToString());
            }
            catch
            {
                return("-1");
            }
        }
Exemple #2
0
        public JsonResult Getir(int id)
        {
            TravelaEntities    db       = new TravelaEntities();
            CustomerT          customer = db.CustomerT.FirstOrDefault(f => f.customerid == id);
            CustomerPopupModel model    = new CustomerPopupModel();

            model.customerid      = customer.customerid;
            model.customername    = customer.customername;
            model.customersurname = customer.customersurname;
            model.birthdate       = customer.birthdate;
            model.phone           = customer.phone;
            model.email           = customer.email;
            model.address         = customer.address;
            return(Json(model, JsonRequestBehavior.AllowGet));
        }
        public ActionResult CustomerPopup(CustomerPopupModel model)
        {
            int pageIndex = model.Page ?? 1;
            var customer  = _customerService.GetAll().Where(x =>
                                                            (string.IsNullOrEmpty(model.CusName) ||
                                                             x.Name.Trim().ToLower().Contains(model.CusName.Trim().ToLower()))
                                                            ).ToList();
            var cutomerlistpopup = _mapper.Map <List <CustomerListPopup> >(customer);

            model.CustomerListPopups = cutomerlistpopup.OrderByDescending(x => x.Id).ToPagedList(pageIndex, 5);
            if (Request.IsAjaxRequest())
            {
                return(PartialView("CustomerListPopup", model));
            }
            return(PartialView("_CustomerPopup", model));
        }
Exemple #4
0
        // GET: CustomerPopup
        public ActionResult Index()
        {
            CustomerPopupModel model = new CustomerPopupModel();

            return(View(model));
        }