Example #1
0
        public async Task <IActionResult> Create([Bind("id,infsystem ,position,sp")] law lw)
        {
            if (ModelState.IsValid)
            {
                string        inform = "";
                int           item1  = 0;
                List <string> inf    = new List <string> {
                };
                List <int> numberinf = new List <int> {
                };
                for (int i = 0; lw.infsystem.Length > i; i++)
                {
                    if (lw.infsystem.Substring(i, 1) != ";")
                    {
                        inform = inform + lw.infsystem.Substring(i, 1);
                    }
                    else
                    {
                        inf.Add(inform);
                        numberinf.Add(item1);
                        item1++;
                        inform = "";
                    }
                }
                string        pos      = "";
                List <string> posit    = new List <string> {
                };
                List <int> numberposit = new List <int> {
                };
                int item = 0;
                for (int i = 0; lw.position.Length > i; i++)
                {
                    if (lw.position.Substring(i, 1) != ";")
                    {
                        pos = pos + lw.position.Substring(i, 1);
                    }
                    else
                    {
                        posit.Add(pos);
                        numberposit.Add(item);
                        item++;
                        pos = "";
                    }
                }
                HttpContext.Session.SetString("spodr", lw.sp);
                HttpContext.Session.SetObjectAsJson("numberposit", numberposit);
                HttpContext.Session.SetObjectAsJson("nemberinf", numberinf);
                HttpContext.Session.SetObjectAsJson("posit", posit);
                HttpContext.Session.SetObjectAsJson("inf", inf);
                _context.Add(lw);
                await _context.SaveChangesAsync();

                return(Redirect("../Tablelaws/Create"));
                // return RedirectToAction(nameof(Index));
            }
            return(View("../DocumentsIBs/Index", await _context.DocumentsIB.ToListAsync()));
        }
Example #2
0
        public async Task <IActionResult> Create([Bind("id,address,port,login,password")] Mail mail)
        {
            if (ModelState.IsValid)
            {
                _context.Add(mail);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(mail));
        }
Example #3
0
        public async Task <IActionResult> Create([Bind("id,ListSystem,lvrol")] InformationSystem informationSystem)
        {
            if (ModelState.IsValid)
            {
                _context.Add(informationSystem);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(informationSystem));
        }
Example #4
0
        public async Task <IActionResult> Create([Bind("id,name,text")] DocumentsIB documentsIB)
        {
            if (ModelState.IsValid)
            {
                _context.Add(documentsIB);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(documentsIB));
        }
Example #5
0
        public async Task <IActionResult> Create([Bind("id,subdiv,group")] Subdivition subdivition)
        {
            if (ModelState.IsValid)
            {
                _context.Add(subdivition);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(subdivition));
        }
Example #6
0
        public async Task <IActionResult> Create([Bind("id,examp")] example example)
        {
            if (ModelState.IsValid)
            {
                _context.Add(example);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(example));
        }
Example #7
0
        public async Task <IActionResult> Create([Bind("id,rollic")] Rool rool)
        {
            if (ModelState.IsValid)
            {
                _context.Add(rool);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(rool));
        }
Example #8
0
        public async Task <IActionResult> Create([Bind("id,Position,postlistlvl")] PostList postList)
        {
            if (ModelState.IsValid)
            {
                _context.Add(postList);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(postList));
        }
Example #9
0
        public async Task <IActionResult> Create(List <string> names, [Bind("id, fio, subdivision, numberphone, numberroom, inventorynumber, position, documents, baseservers, leadersubdivision, informationsystem, departmentib, departmentoz, status, marh, namecreated,  deportmencreated, positcreated, login, emailcreated, signIT, olduser, neuser")] Request request)
        {
            if (ModelState.IsValid)
            {
                using (var context = new PrincipalContext(ContextType.Domain, "astroblgaz.local"))//из объекта userprincipal можно получить информацию из AD
                {
                    var user = UserPrincipal.FindByIdentity(context, request.fio);
                    if (request.olduser == true)
                    {
                        if (user != null)
                        {
                            request.login            = user.SamAccountName;
                            request.namecreated      = HttpContext.Session.GetString("Name");
                            request.positcreated     = HttpContext.Session.GetString("Dolzh");
                            request.deportmencreated = HttpContext.Session.GetString("Deportment");
                            request.emailcreated     = HttpContext.Session.GetString("Email");
                            _context.Add(request);
                            await _context.SaveChangesAsync();

                            return(RedirectToAction(nameof(Index)));
                        }
                    }
                    else
                    {
                        string   ret = "";
                        int      st  = 0;
                        string[] rus = { "А", "а", "Б", "б", "В", "в", "Г", "г", "Д", "д", "Е", "е", "Ё", "ё", "Ж", "ж", "З", "з", "И", "и", "Й", "й", "К", "к", "Л", "л", "М", "м", "Н", "н",
                                         "О", "о", "П", "п", "Р", "р", "С", "с", "Т", "т", "У", "у", "Ф", "ф", "Х", "х", "Ц", "ц", "Ч", "ч", "Ш", "ш", "Щ", "щ", "Ъ", "ъ", "Ы", "ы", "Ь", "ь",
                                         "Э", "э", "Ю", "ю", "Я", "я" };
                        string[] eng = { "a", "a", "b",  "b",  "v",  "v", "g", "g", "d", "d", "e", "e", "e", "e", "zh", "zh", "z", "z", "i",  "i",  "y",  "y",  "k",    "k",    "l",  "l",  "m", "m", "n",  "n",
                                         "o", "o", "p",  "p",  "r",  "r", "s", "s", "t", "t", "u", "u", "f", "f", "kh", "kh", "c", "c", "ch", "ch", "sh", "sh", "shch", "shch", null, null, "y", "y", null, null,
                                         "e", "e", "yu", "yu", "ya", "ya" };
                        string[] rus1 = { "А", null, "Б", null, "В", null, "Г", null, "Д", null, "Е", null, "Ё", null, "Ж", null, "З", null, "И", null, "Й", null, "К", null, "Л", null, "М", null, "Н", null,
                                          "О", null, "П", null, "Р", null, "С", null, "Т", null, "У", null, "Ф", null, "Х", null, "Ц", null, "Ч", null, "Ш", null, "Щ", null, "Ъ", null, "Ы", null, "Ь", null,
                                          "Э", null, "Ю", null, "Я", null };
                        string[] eng1 = { "a", null, "b",  null, "v",  null, "g", null, "d", null, "e", null, "e", null, "zh", null, "z", null, "i",  null, "y",  null, "k",    null, "l",  null, "m", null, "n",  null,
                                          "o", null, "p",  null, "r",  null, "s", null, "t", null, "u", null, "f", null, "kh", null, "c", null, "ch", null, "sh", null, "dhch", null, null, null, "y", null, null, null,
                                          "e", null, "yu", null, "ya", null };
                        for (int j = 0; j < request.fio.Length; j++)
                        {
                            for (int i = 0; i < rus.Length; i++)
                            {
                                if (request.fio.Substring(j, 1) == " " && st == 0)
                                {
                                    ret += ".";
                                    st   = 1;
                                }
                                if (request.fio.Substring(j, 1) == rus[i] && st == 0)
                                {
                                    ret += eng[i];
                                }
                                if (request.fio.Substring(j, 1) == rus1[i] && st == 1)
                                {
                                    ret += eng1[i];
                                }
                            }
                        }
                        request.login            = ret;
                        request.namecreated      = HttpContext.Session.GetString("Name");
                        request.positcreated     = HttpContext.Session.GetString("Dolzh");
                        request.deportmencreated = HttpContext.Session.GetString("Deportment");
                        request.emailcreated     = HttpContext.Session.GetString("Email");
                        string strok  = "";
                        string strok2 = "";
                        int    count  = 0;
                        int    first  = 0;
                        for (int item = 0; item < names.Count; item++)
                        {
                            count = 0;
                            foreach (var hh in names[item])
                            {
                                if (hh != '*')
                                {
                                    strok = strok + hh;
                                }
                                if (hh == ';' || hh == '*')
                                {
                                    count++;
                                    if (count == 1)
                                    {
                                        if (strok == request.position)
                                        {
                                            first = 1;
                                        }
                                    }
                                    if (first == 1 && count == 2)
                                    {
                                        strok2 = strok2 + strok + "-";
                                    }
                                    if (first == 1 && count == 3)
                                    {
                                        strok2 = strok2 + strok;
                                        first  = 0;
                                    }
                                    strok = "";
                                }
                            }
                        }
                        request.informationsystem = strok2;
                        _context.Add(request);
                    }
                    await _context.SaveChangesAsync();

                    return(RedirectToAction(nameof(Index)));
                }
            }

            return(View(request));
        }
Example #10
0
        public async Task <IActionResult> Create(List <string> names, [Bind("id,isystem,pos,spod,role")] Tablelaw lw)
        {
            int           id     = lw.id;
            string        prov   = "";
            int           znak   = 0;
            int           indexI = 0;
            int           indexJ = 0;
            List <string> G      = new List <string> {
            };
            var proverka2        = await _context.Tablelaws.ToListAsync();

            foreach (var GG in proverka2)
            {
                G.Add(GG.spod);
                G.Add(GG.pos);
                G.Add(GG.isystem);
            }

            for (int i = 0; HttpContext.Session.GetObjectFromJson <List <string> >("posit").Count > i; i++)
            {
                for (int j = 0; HttpContext.Session.GetObjectFromJson <List <string> >("inf").Count > j; j++)
                {
                    for (int item = 0; item < names.Count; item++)
                    {
                        indexI = 0;
                        indexJ = 0;
                        znak   = 0;

                        foreach (var index in names[item])
                        {
                            if (index != ';')
                            {
                                prov = prov + index;
                            }
                            else
                            {
                                if (indexI == 1 && indexJ == 1)
                                {
                                    lw.role = lw.role + prov + ";";
                                }
                                if (znak == 1 && Convert.ToInt32(prov) == j)
                                {
                                    indexJ = 1;
                                }
                                if (znak == 0 && Convert.ToInt32(prov) == i)
                                {
                                    indexI = 1;
                                }
                                znak++;
                                prov = "";
                            }
                        }
                    }
                    lw.pos     = HttpContext.Session.GetObjectFromJson <List <string> >("posit")[i];
                    lw.isystem = HttpContext.Session.GetObjectFromJson <List <string> >("inf")[j];
                    lw.spod    = HttpContext.Session.GetString("spodr");
                    lw.id      = 0;
                    int flag      = 0;
                    var proverka1 = await _context.Tablelaws.ToListAsync();

                    if (proverka1.Count != 0)
                    {
                        for (int ced = 0; ced < G.Count; ced = ced + 3)
                        {
                            if (G[ced] == lw.spod)
                            {
                                if (G[ced + 1] == lw.pos)
                                {
                                    if (G[ced + 2] == lw.isystem)
                                    {
                                        HttpContext.Session.SetObjectAsJson("errors", lw.role);
                                        flag = 1;
                                    }
                                }
                            }
                        }
                    }
                    else if (proverka1.Count == 0)
                    {
                        _context.Add(lw);
                        await _context.SaveChangesAsync();
                    }
                    if (flag == 0)
                    {
                        _context.Add(lw);
                        await _context.SaveChangesAsync();
                    }
                    lw.role = "";
                }
            }
            return(RedirectToAction(nameof(Index)));

            /* if (ModelState.IsValid)
             * {
             *   _context.Add(lw);
             *   await _context.SaveChangesAsync();
             *   return View("../DocumentsIBs/Index", await _context.DocumentsIB.ToListAsync());
             *   // return RedirectToAction(nameof(Index));
             * }*/
            // return View("../DocumentsIBs/Index", await _context.DocumentsIB.ToListAsync());
        }