Beispiel #1
0
        //افزدون پرداخت
        public async Task <IActionResult> AddAccounting([Bind("ServiceRequsetId,PayType,Payed,PayDate,NextPay,TrackNumber,Comment")] Accounting accounting, string pay, string next)
        {
            var PayDate = pay.ToGregorianDateTime();
            var NextPay = next.ToGregorianDateTime();

            if (!PayDate.HasValue)
            {
                ModelState.AddModelError("PayDate", "تاریخ پرداخت اشتباه است");
            }
            if (!NextPay.HasValue)
            {
                ModelState.AddModelError("NextPay", "تاریخ سررسید اشتباه است");
            }
            if (ModelState.IsValid)
            {
                accounting.PayDate = PayDate;
                accounting.NextPay = NextPay;

                _context.Add(accounting);
                await _context.SaveChangesWithHistoryAsync(HttpContext);

                return(RedirectToAction(nameof(Accounting), new { id = accounting.ServiceRequsetId }));
            }
            return(View(accounting));
        }
        public async Task <IActionResult> Create([Bind("ID,dropOffLat,pdropOffLat,pickUpLat,pickUpLon")] TaxiTrip taxiTrip)
        {
            if (ModelState.IsValid)
            {
                _context.Add(taxiTrip);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(taxiTrip));
        }
Beispiel #3
0
        public async Task <IActionResult> Create([Bind("Id,Name,CityPercent")] City city)
        {
            if (ModelState.IsValid)
            {
                _context.Add(city);
                await _context.SaveChangesWithHistoryAsync(HttpContext);

                return(RedirectToAction(nameof(Index)));
            }
            return(View(city));
        }
Beispiel #4
0
        public async Task <IActionResult> Create([Bind("Id,Name,LastName,Age,Gender,Password,PhoneNubmber,IsMobielVerifed,Email,IsEmailVerified,AvatarPath,BirthDay,AllowActivity")] StudentParent studentParent)
        {
            if (ModelState.IsValid)
            {
                _context.Add(studentParent);
                await _context.SaveChangesWithHistoryAsync(HttpContext);

                return(RedirectToAction(nameof(Index)));
            }
            return(View(studentParent));
        }
Beispiel #5
0
        public async Task <IActionResult> Create([Bind("Id,Name,Age,Password,PhoneNubmber,Age,Email,AllowActivity,RegisterCompanyNumber,RelaseDate,ExpireDate")] Contractor contractor)
        {
            if (ModelState.IsValid)
            {
                _context.Add(contractor);
                await _context.SaveChangesWithHistoryAsync(HttpContext);

                return(RedirectToAction(nameof(Index)));
            }
            return(View(contractor));
        }
Beispiel #6
0
        public async Task <IActionResult> Create([Bind("Id,Name")] AcademyCategory academyCategory)
        {
            if (ModelState.IsValid)
            {
                _context.Add(academyCategory);
                await _context.SaveChangesWithHistoryAsync(HttpContext);

                return(RedirectToAction(nameof(Index)));
            }
            return(View(academyCategory));
        }
Beispiel #7
0
        public async Task <IActionResult> Create([Bind("Id,Name,DriverId,DriverPercent")] TaxiService taxiCab)
        {
            if (ModelState.IsValid)
            {
                _context.Add(taxiCab);
                await _context.SaveChangesWithHistoryAsync(HttpContext);

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DriverId"] = new SelectList(_context.Drivers.Undelited(), "Id", "Name", taxiCab.DriverId);
            return(View(taxiCab));
        }
        public async Task <IActionResult> Create([Bind("Id,Name,CityId,DistrictPercent")] District district)
        {
            if (ModelState.IsValid)
            {
                _context.Add(district);
                await _context.SaveChangesWithHistoryAsync(HttpContext);

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CityId"] = new SelectList(_context.Cities, "Id", "Name", district.CityId);
            return(View(district));
        }
Beispiel #9
0
        public async Task <IActionResult> Create([Bind("Id,Name,DriverId,DriverPercent,ServiceType")] TaxiService taxiService)
        {
            if (ModelState.IsValid)
            {
                taxiService.TaxiCabState = TaxiCabState.wait;
                _context.Add(taxiService);
                await _context.SaveChangesWithHistoryAsync(HttpContext);

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DriverId"] = new SelectList(_context.Drivers.Undelited().Where(c => c.ContractorId == User.GetContractor().Id), "Id", "Name", taxiService.DriverId);
            return(View(taxiService));
        }
Beispiel #10
0
        public async Task <IActionResult> Create([Bind("OrderID,ClientID,DriverID,CarID,DepPlace,DestPlace,Time")] Order order)
        {
            if (ModelState.IsValid)
            {
                _context.Add(order);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            DriversDropDownList(order.DriverID);
            ClientsDropDownList(order.ClientID);
            CarsDropDownList(order.CarID);
            return(View(order));
        }
Beispiel #11
0
        public async Task <IActionResult> Create([Bind("Address,DistrictId,AcademyCategoryId,SupportNumber,Id,Name,Password,PhoneNubmber,AllowActivity,ContractorId,AcademyPercent")] Academy academy)
        {
            if (ModelState.IsValid)
            {
                _context.Add(academy);
                await _context.SaveChangesWithHistoryAsync(HttpContext);

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AcademyCategoryId"] = new SelectList(_context.AcademyCategories, "Id", "Name", academy.AcademyCategoryId);
            ViewData["DistrictId"]        = new SelectList(_context.Districts, "Id", "Name", academy.DistrictId);
            ViewData["ContractorId"]      = new SelectList(_context.Contractors, "Id", "FullName");

            return(View(academy));
        }
Beispiel #12
0
        public async Task <IActionResult> Create([Bind("CarName,CarType,CarColor,IranianIdCode,DrivingLicense,DriverCode,PelakNumber,IsMaried,Id,Token,Name,PhoneNubmber,Password,BeginDate,AllowActivity")] Driver driver, IFormFile AvatarPath)
        {
            if (AvatarPath == null)
            {
                ModelState.AddModelError(nameof(AvatarPath), "تصویر راننده  باید وارد شود");
            }
            if (AvatarPath != null && AvatarPath.Length > (500 * 1024))
            {
                ModelState.AddModelError(nameof(AvatarPath), "حجم تصویر نباید بیش از 500 کیلو بایت باشد");
            }
            driver.ContractorId = User.GetContractor().Id;

            if (ModelState.IsValid)
            {
                try
                {
                    List <string> AllowedExtention = new List <string>()
                    {
                        ".jpg",
                        ".png"
                    };


                    var data = await AlphaRest.File.SendFileAsync(AvatarPath, AllowedExtention, (500 * 1024), $"{Const.DriverUploadFileApi}");

                    if (data != null && data != "false")
                    {
                        driver.AvatarPath = data;
                    }
                    else
                    {
                        ModelState.AddModelError(nameof(AvatarPath), "تصویر آپلود نشد");
                        return(View(driver));
                    }

                    _context.Add(driver);
                    await _context.SaveChangesWithHistoryAsync(HttpContext);

                    return(RedirectToAction(nameof(Details), new { id = driver.Id }));
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            return(View(driver));
        }
Beispiel #13
0
        public async Task <IActionResult> Create([Bind("CarNumber,CarClass,CarSize")] Car car)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    _context.Add(car);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction(nameof(Index)));
                }
            }
            catch (DbUpdateException /* ex */)
            {
                //Log the error (uncomment ex variable name and write a log.
                ModelState.AddModelError("", "Unable to save changes. " +
                                         "Try again, and if the problem persists " +
                                         "see your system administrator.");
            }
            return(View(car));
        }
Beispiel #14
0
        public async Task <IActionResult> Register([Bind("Id,Name,LastName,Gender,IrIdCod,StudentCode,Age,PhoneNubmber,AcademyId,Hs_Change,IsDeleted,AccesptTerms")] StudentParent student)
        {
            if (student.AccesptTerms == false)
            {
                ModelState.AddModelError(nameof(student.AccesptTerms), "پذیرفتن قوانین و مقررات  برای ثبت نام الزامی است");
            }
            if (!student.IrIdCod.IsValidIranianNationalCode())
            {
                ModelState.AddModelError(nameof(student.IrIdCod), "کد ملی وارد شده معتبر نیست");
            }
            if (!student.PhoneNubmber.IsValidIranianMobileNumber())
            {
                ModelState.AddModelError(nameof(student.PhoneNubmber), "شماره موبایل وارد شده معتبر نیست (انگلیسی تایپ شود)");
            }
            if (ModelState.IsValid)
            {
                student.PhoneNubmber = student.PhoneNubmber.ToEnglishNumbers();
                student.StudentCode  = student.StudentCode.ToEnglishNumbers();
                student.IrIdCod      = student.IrIdCod.ToEnglishNumbers();

                var exsit = await _context.studentParents.AnyAsync(
                    c => c.IrIdCod == student.IrIdCod ||
                    c.StudentCode == student.StudentCode);

                if (exsit == false)
                {
                    try
                    {
                        StudentParent studentparent = new StudentParent()
                        {
                            AllowActivity = true,
                            Name          = student.Name,
                            LastName      = student.LastName,
                            Hs_Change     = student.Hs_Change,
                            IsDeleted     = student.IsDeleted,
                            Password      = student.IrIdCod,
                            PhoneNubmber  = student.PhoneNubmber,
                            Gender        = student.Gender,
                            Age           = student.Age,
                            StudentCode   = student.StudentCode,
                            AcademyId     = student.AcademyId,
                            AccesptTerms  = student.AccesptTerms
                        };
                        _context.Add(student);
                        _context.Add(studentparent);
                        await _context.SaveChangesWithHistoryAsync(HttpContext);
                    }
                    catch (System.Exception ex)
                    {
                        throw;
                    }

                    return(RedirectToAction(nameof(result), new { state = true }));
                }
                else
                {
                    ModelState.AddModelError("", "این مشخصات از قبل در سامانه وجود دارد");
                    ViewData["AcademyId"] = new SelectList(_context.academies, "Id", "Name", student.AcademyId);
                    return(View(student));
                }
            }
            ViewData["AcademyId"] = new SelectList(_context.academies, "Id", "Name", student.AcademyId);
            return(View(student));
        }