Ejemplo n.º 1
0
        public IActionResult OnPost(string stDate = "", string endDate = "")
        {
            if (!ModelState.IsValid && _orderServices.isExistcode(Discount.Discountcode))
            {
                return(Page());
            }

            if (stDate != "")
            {
                string[] std = stDate.Split('/');
                Discount.StartDate = new DateTime(int.Parse(std[0]),
                                                  int.Parse(std[1]),
                                                  int.Parse(std[2]),
                                                  new PersianCalendar()
                                                  );
            }

            if (endDate != "")
            {
                string[] end = endDate.Split('/');
                Discount.EndDate = new DateTime(int.Parse(end[0]),
                                                int.Parse(end[1]),
                                                int.Parse(end[2]),
                                                new PersianCalendar()
                                                );
            }

            _orderServices.Adddiscont(Discount);

            return(RedirectToPage("Index"));
        }