Esempio n. 1
0
        //
        // GET: /CustomerLevel/Create


        public ActionResult Create()
        {
            CustomerLevelModel CustomerLevel = new CustomerLevelModel();

            CustomerLevel.Actived = true;
            return(View(CustomerLevel));
        }
Esempio n. 2
0
 public ActionResult Edit(CustomerLevelModel CustomerLevel)
 {
     if (ModelState.IsValid)
     {
         db.Entry(CustomerLevel).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(CustomerLevel));
 }
Esempio n. 3
0
        //
        // GET: /CustomerLevel/Edit/5


        public ActionResult Edit(int id = 0)
        {
            CustomerLevelModel CustomerLevel = db.CustomerLevelModel.Find(id);

            if (CustomerLevel == null)
            {
                return(HttpNotFound());
            }
            return(View(CustomerLevel));
        }
Esempio n. 4
0
 public async Task <CustomerLevel> Save(CustomerLevelModel customerLevel)
 {
     try
     {
         var customerLevelDto = _mapper.Map <CustomerLevelModel, CustomerLevel>(customerLevel);
         return(await _customerLevelManager.Save(customerLevelDto));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 5
0
 public async Task <bool> IsCheckSumInvest(CustomerLevelModel customerLevel)
 {
     try
     {
         var customerLevelDto = _mapper.Map <CustomerLevelModel, CustomerLevel>(customerLevel);
         return(await _customerLevelManager.IsCheckSumInvest(customerLevelDto));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 6
0
        public ActionResult Edit(CustomerLevelModel model, bool continueEditing)
        {
            if (ModelState.IsValid)
            {
                var entity = _levelService.GetCustomerLevelById(model.Id);
                entity = model.MapTo <CustomerLevelModel, CustomerLevel>(entity);
                _levelService.UpdateLevel(entity);

                if (continueEditing)
                {
                    return(RedirectToAction("Edit", new { id = model.Id }));
                }
                return(RedirectToAction("Index"));
            }

            return(View(model));
        }
Esempio n. 7
0
        public ActionResult Create(CustomerLevelModel model, bool continueEditing)
        {
            if (ModelState.IsValid)
            {
                var entity = model.MapTo <CustomerLevel>();

                var levelId = _levelService.InsertLevel(entity);

                if (continueEditing)
                {
                    return(RedirectToAction("Edit", new { id = levelId }));
                }
                return(RedirectToAction("Index"));
            }

            return(View(model));
        }
Esempio n. 8
0
        public ActionResult Create(CustomerLevelModel CustomerLevel)
        {
            if (ModelState.IsValid)
            {
                db.CustomerLevelModel.Add(CustomerLevel);
                db.SaveChanges();
                using (System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString))
                {
                    using (System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand())
                    {
                        cmd.CommandText = "usp_InsertPrice";
                        cmd.Parameters.AddWithValue("@CustomerLevelId", CustomerLevel.CustomerLevelId);
                        cmd.Connection  = conn;
                        cmd.CommandType = CommandType.StoredProcedure;
                        conn.Open();
                        cmd.ExecuteNonQuery();
                        conn.Close();
                    }
                }
                return(RedirectToAction("Index"));
            }

            return(View(CustomerLevel));
        }
Esempio n. 9
0
        public ActionResult Create()
        {
            var model = new CustomerLevelModel();

            return(View(model));
        }
        public async Task <IActionResult> New(CustomerLevelModel customerLevel)
        {
            try
            {
                if (customerLevel == null)
                {
                    return(Json(false, new JsonSerializerSettings()));
                }
                if (!ModelState.IsValid)
                {
                    return(View(customerLevel));
                }

                @ViewBag.CheckValue = string.Empty;
                @ViewBag.CheckName  = string.Empty;

                if (string.IsNullOrEmpty(customerLevel.NameCustomerLevel))
                {
                    @ViewBag.CheckName = "Tên phân cấp khách hàng không được để trống";
                    return(View(customerLevel));
                }

                var checkName = _customerLevelService.IsDuplicateName(customerLevel.NameCustomerLevel, customerLevel.IDCustomerLevel).Result;

                if (!checkName)
                {
                    @ViewBag.CheckName = "Tên phân cấp khách hàng đã tồn tại";
                    return(View(customerLevel));
                }
                if (customerLevel.MinMoney == null && customerLevel.MaxMoney == null)
                {
                    @ViewBag.CheckValue = "Tổng số tiền đầu tư không được để trống";
                    return(View(customerLevel));
                }
                if (customerLevel.MinMoney == 0 && customerLevel.MaxMoney == 0)
                {
                    @ViewBag.CheckValue = "Giá trị không hợp lệ";
                    return(View(customerLevel));
                }
                if (customerLevel.MinMoney > customerLevel.MaxMoney)
                {
                    @ViewBag.CheckValue = "Số tiền Từ phải nhỏ hơn Số tiền Đến";
                    return(View(customerLevel));
                }
                var checkStatus = await _customerLevelService.IsCheckSumInvest(customerLevel);

                if (!checkStatus)
                {
                    @ViewBag.CheckValue = "Giá trị đã tồn tại";
                    return(View(customerLevel));
                }
                //
                if (customerLevel.MaxMoney == null)
                {
                    customerLevel.MaxMoney = Common.Constants.MaxDecimal.MaxMoney;
                }

                var result = await _customerLevelService.Save(customerLevel);
            }
            catch (System.Exception ex)
            {
                throw ex;
            }

            return(RedirectToAction("List"));
        }