public IActionResult RegisterCashDesk(RegisterCashDeskViewModel model)
        {
            if (User.IsInRole("blocked") || User.IsInRole("operator"))
            {
                return(RedirectToAction("BlockPage", "BlockedUser"));
            }

            var    pattern      = "SWK";
            var    number       = 10000000 + _context.Kkms.Count() + 1;
            string res          = number.ToString().Substring(1);
            string serialNumber = pattern + res;

            var user = _userManager.Users.FirstOrDefault(i => i.Id == model.UserId);

            if (user != null)
            {
                Kkm kkm = new Kkm
                {
                    Name          = model.Name,
                    Description   = model.Description,
                    SerialNumber  = serialNumber,
                    UserId        = user.Id,
                    CurrentStatus = "Создана",
                    Address       = user.Address,
                    Mode          = "Режим отправки в ОФД",
                    NameOrg       = user.Title,
                    Iin           = user.Inn
                };
                _context.Kkms.Add(kkm);
            }

            _context.SaveChanges();

            return(RedirectToAction("GetCashDesk", "InitializeCashDesk", new { id = model.UserId }));
        }
        public IActionResult CheckName(RegisterCashDeskViewModel model)
        {
            if (User.IsInRole("blocked") || User.IsInRole("operator"))
            {
                return(RedirectToAction("BlockPage", "BlockedUser"));
            }

            List <Kkm> reskkm = _context.Kkms.Where(u => u.UserId == model.UserId).ToList();

            var res = reskkm.FirstOrDefault(i => i.Name == model.Name);

            if (res != null)
            {
                return(Ok(false));
            }

            var org = new global::Models.DTO.RequestOperatorOfd.Org();

            return(Ok(true));
        }
Ejemplo n.º 3
0
        public IActionResult CheckName(RegisterCashDeskViewModel model)
        {
            if (User.IsInRole("blocked"))
            {
                return(RedirectToAction("BlockPage", "BlockedUser"));
            }

            var kkm = new Kkm
            {
                Name        = model.Name,
                Description = model.Description,
            };

            if (_context.Kkms.Any(u => string.Equals(u.Name.Trim(), model.Name) && u.Id == kkm.Id))
            {
                return(Ok(true));
            }
            else if (_context.Kkms.Any(u => string.Equals(u.Name.Trim(), model.Name)))
            {
                return(Ok(false));
            }

            return(Ok(true));
        }