コード例 #1
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));
        }
コード例 #2
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));
        }
コード例 #3
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));
        }
コード例 #4
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));
        }
コード例 #5
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));
        }
コード例 #6
0
        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));
        }
コード例 #7
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));
        }
コード例 #8
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));
        }
コード例 #9
0
        public async Task <IActionResult> Registerdriver([FromBody] RegisterDriverViewModel model)
        {
            try
            {
                if (CheckExistdriver(model.PhoneNubmber))
                {
                    return(Ok(new ResultContract <Driver>()
                    {
                        statuse = false, Data = null, message = "این شماره موبایل قبلا ثبت نام کرده است"
                    }));
                }
                else
                {
                    var driver = model.Adapt <Driver>();

                    await _context.Drivers.AddAsync(driver);

                    await _context.SaveChangesWithHistoryAsync(HttpContext);

                    return(Ok(new ResultContract <Driver>()
                    {
                        statuse = true, Data = driver, message = ""
                    }));
                }
            }
            catch (Exception ex)
            {
                await _logger.LogAsync(HttpContext, ex);

                return(Ok(new ResultContract <string>()
                {
                    statuse = false, message = "یک خطای ناشناخته روی داد"
                }));
            }
        }
コード例 #10
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,SiteName,LogoPath,VanPercent,TaxiPercent")] GeneralSetting generalSetting)
        {
            if (id != generalSetting.Id)
            {
                return(NotFound());
            }
            if (generalSetting.TaxiPercent <= 0)
            {
                ModelState.AddModelError("TaxiPercent", "مقدار صفر برای قیمت پایه تاکسی سواری مجاز نیست");
            }
            if (generalSetting.VanPercent <= 0)
            {
                ModelState.AddModelError("VanPercent", "مقدار صفر برای قیمت پایه تاکسی ون مجاز نیست");
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(generalSetting);
                    await _context.SaveChangesWithHistoryAsync(HttpContext);
                }
                catch (DbUpdateConcurrencyException ex)
                {
                    throw ex;
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(generalSetting));
        }
コード例 #11
0
ファイル: HomeController.cs プロジェクト: Alibesharat/20RO
        //تغییر وضعیت درخواست
        public async Task <IActionResult> ChangeState(string id, RequsetSate requsetSate)
        {
            var serviceRequset = await _context.ServiceRequsets
                                 .Include(c => c.Academy)
                                 .FirstOrDefaultAsync(m => m.Id == id && m.Academy.ContractorId == User.GetContractor().Id);

            if (serviceRequset == null || serviceRequset.RequsetState == RequsetSate.AwaitingAcademy)
            {
                return(NotFound());
            }
            try
            {
                if (requsetSate == RequsetSate.AwaitingAcademy)
                {
                    ViewBag.msg = "ثبت این وضعیت به عهده مدرسه است";
                    return(View(serviceRequset));
                }
                serviceRequset.RequsetState = requsetSate;
                _context.Update(serviceRequset);
                await _context.SaveChangesWithHistoryAsync(HttpContext);

                ViewBag.msg = "تغییر وضعیت با موفقیت انجام شد";
                return(View(serviceRequset));
            }
            catch (DbUpdateException ex)
            {
                throw ex;
            }
        }
コード例 #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));
        }
コード例 #13
0
        public async Task <IActionResult> Edit(int id, [Bind("CarName,CarType,CarColor,IranianIdCode,DrivingLicense,DriverCode,PelakNumber,CityId,IsMaried,HasPlan,Id,Name,LastName,Age,Gender,Password,PhoneNubmber,IsMobielVerifed,Email,IsEmailVerified,BirthDay,BeginDate,AllowActivity,ContractorId")] Driver driver, IFormFile AvatarPath)
        {
            if (AvatarPath != null && AvatarPath.Length > (500 * 1024))
            {
                ModelState.AddModelError(nameof(AvatarPath), "حجم تصویر نباید بیش از 500 کیلو بایت باشد");
            }
            if (id != driver.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                if (AvatarPath != null)
                {
                    List <string> AllowedExtention = new List <string>()
                    {
                        ".jpg",
                        ".png"
                    };
                    var data = await AlphaRest.File.SendFileAsync(AvatarPath, AllowedExtention, (500 * 1024), $"{Const.StudentparrentPath}/api/api/Getdriverpic");

                    if (!string.IsNullOrWhiteSpace(data) && data != "false")
                    {
                        driver.AvatarPath = data;
                    }
                }
                try
                {
                    _context.Update(driver);
                    await _context.SaveChangesWithHistoryAsync(HttpContext);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DriverExists(driver.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(driver));
        }
コード例 #14
0
        public async Task <IActionResult> Edit(string id, [Bind("Id,StudentParrentId,FullName,Age,Address,Note,CourseId,RequsetState")] ServiceRequset serviceRequset)
        {
            if (id != serviceRequset.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(serviceRequset);
                    await _context.SaveChangesWithHistoryAsync(HttpContext);
                }
                catch (DbUpdateConcurrencyException)
                {
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["StudentParrentId"] = new SelectList(_context.StudentParents, "Id", "Name", serviceRequset.StudentParrentId);
            return(View(serviceRequset));
        }
コード例 #15
0
ファイル: HomeController.cs プロジェクト: Alibesharat/20RO
        //تغییر وضعیت درخواست
        public async Task <IActionResult> ChangeState(string id, RequsetSate RequsetState)
        {
            var serviceRequset = await _context.ServiceRequsets
                                 .FirstOrDefaultAsync(m => m.Id == id && m.AcademyId == User.GetAcademy().Id);

            if (serviceRequset == null)
            {
                return(NotFound());
            }
            try
            {
                serviceRequset.RequsetState = RequsetState;
                _context.Update(serviceRequset);
                await _context.SaveChangesWithHistoryAsync(HttpContext);

                ViewBag.msg = "تغییر وضعیت با موفقیت انجام شد";
                return(View(serviceRequset));
            }
            catch (DbUpdateException ex)
            {
                throw ex;
            }
        }
コード例 #16
0
ファイル: homeController.cs プロジェクト: Alibesharat/20RO
        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));
        }