Пример #1
0
        public async Task <IActionResult> ChangeState([FromBody] ChangestateViewModel model)
        {
            try
            {
                #region بررسی اعتبار درخواست کننده
                var taxtiCab = await _context.TaxiServices.Undelited().FirstOrDefaultAsync(c => c.Id == model.TaxiCabId);

                if (taxtiCab == null || taxtiCab.DriverId != model.DriverId)
                {
                    await _logger.LogAsync(HttpContext, $"{nameof(taxtiCab)} Is NULL");

                    return(Ok(new ResultContract <bool>()
                    {
                        statuse = false, Data = false, message = "مشکلی بوجود آمد"
                    }));
                }
                #endregion

                var Service = await _context.ServiceRequsets.Include(c => c.StudentParent).FirstOrDefaultAsync(c => c.Id == model.RequseteId);

                if (Service == null)
                {
                    await _logger.LogAsync(HttpContext, $"{nameof(Service)} Is NULL");

                    return(Ok(new ResultContract <bool>()
                    {
                        statuse = false, Data = false, message = "مشکلی بوجود آمد"
                    }));
                }

                Service.NotifState = model.NotifState;
                _context.Update(Service);
                await _context.SaveChangesAsync();

                var    number = Service.StudentParent.PhoneNubmber;
                string token  = Service.Id;
                if (model.NotifState == NotifState.GetOn)
                {
                    await _notify.SendNotifyWithTemplateAsync(number, token, MessageTemplate.Bistrogetoff);
                }
                else
                {
                    await _notify.SendNotifyWithTemplateAsync(number, token, MessageTemplate.Bistogeton);
                }

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

                return(Ok(new ResultContract <bool>()
                {
                    statuse = false, Data = false, message = "مشکلی بوجود آمد"
                }));
            }
        }
Пример #2
0
        public async Task <IActionResult> UserChalenge(string phoneNumber)
        {
            if (!phoneNumber.IsValidIranianMobileNumber())
            {
                ViewBag.msg = "شماره تلفن همراه معتبر نمی باشد";
                return(View());
            }
            string token = Const.GeneratRandomNumber();

            await AddCashAsync(phoneNumber, token, 3);

            await _notify.SendNotifyWithTemplateAsync(phoneNumber, token, MessageTemplate.Bisroverify);

            return(RedirectToAction(nameof(ValidateingNumber), new { phoneNumber }));
        }
Пример #3
0
        public async Task <IActionResult> Edit(string id, [Bind("Id,Name,DriverId,TaxiSerivcestate,DriverPercent")] TaxiService taxiCab)
        {
            if (id != taxiCab.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(taxiCab);
                    await _context.SaveChangesWithHistoryAsync(HttpContext);

                    if (taxiCab.TaxiCabState == TaxiCabState.Ready)
                    {
                        var txn = await _context.TaxiServices
                                  .Include(c => c.Passnegers)
                                  .ThenInclude(p => p.StudentParent)
                                  .FirstOrDefaultAsync(c => c.Id == taxiCab.Id);

                        if (txn != null)
                        {
                            foreach (var item in txn.Passnegers)
                            {
                                await _sms.SendNotifyWithTemplateAsync(item.StudentParent.PhoneNubmber, "https://20ro.net/Home/ActiveSerive", MessageTemplate.Bisrobreif);
                            }
                        }
                    }
                }
                catch (DbUpdateConcurrencyException)
                {
                    //if (!TaxiCabExists(taxiCab.Id))
                    //{
                    //    return NotFound();
                    //}
                    //else
                    //{
                    //    throw;
                    //}
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DriverId"] = new SelectList(_context.Drivers.Undelited(), "Id", "Name", taxiCab.DriverId);
            return(View(taxiCab));
        }