Ejemplo n.º 1
0
        public async Task <ActionResult> Login(LoginViewModel model, string returnUrl)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            DMSContext db   = new DMSContext();
            var        user = db.Users.ToList().FirstOrDefault(item => item.Login == model.Email && item.Password == model.Password);
            var        role = db.Roles.ToList().FirstOrDefault(item => item.Id == user.RoleId);

            if (user != null)
            {
                FormsAuthentication.SetAuthCookie(model.Email, false);

                var    authTicket      = new FormsAuthenticationTicket(1, user.Login, DateTime.Now, DateTime.Now.AddMinutes(20), false, role.Name);
                string encryptedTicket = FormsAuthentication.Encrypt(authTicket);
                var    authCookie      = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);
                HttpContext.Response.Cookies.Add(authCookie);
                return(RedirectToAction("Index", "Documents"));
            }

            else
            {
                ModelState.AddModelError("", "Invalid login attempt.");
                return(View(model));
            }
        }
Ejemplo n.º 2
0
 public DocumentController(
     IHostingEnvironment appEnvironment,
     DMSContext context)
 {
     _appEnvironment  = appEnvironment;
     _documentService = new DocumentService(context);
     _categoryService = new CategoryService(context);
 }
Ejemplo n.º 3
0
        public async Task <ActionResult> Register(User model)
        {
            if (ModelState.IsValid)
            {
                DMSContext db = new DMSContext();
                try
                {
                    db.Users.Add(model);
                    return(RedirectToAction("Index", "Home"));
                }
                catch { }
            }

            // Появление этого сообщения означает наличие ошибки; повторное отображение формы
            return(View(model));
        }
Ejemplo n.º 4
0
        private bool ValidateUser(string login, string password)
        {
            bool isValid = false;

            using (DMSContext _db = new DMSContext())
            {
                try
                {
                    User user = (from u in _db.Users
                                 where u.Login == login && u.Password == password
                                 select u).FirstOrDefault();

                    if (user != null)
                    {
                        isValid = true;
                    }
                }
                catch
                {
                    isValid = false;
                }
            }
            return(isValid);
        }
Ejemplo n.º 5
0
 public ShopsController(DMSContext context)
 {
     _context = context;
 }
Ejemplo n.º 6
0
 public CategoryController(DMSContext db)
 {
     _cats = new CategoryService(db);
 }
Ejemplo n.º 7
0
 public CategoryController(DMSContext context)
 {
     _categoryService = new CategoryService(context);
 }
Ejemplo n.º 8
0
 public StocksController(DMSContext context)
 {
     _context = context;
 }
Ejemplo n.º 9
0
 public UserService(DMSContext context)
 {
     _context = context;
 }
Ejemplo n.º 10
0
 public UserController(DMSContext _context, IConfiguration _config)
 {
     _userService = new UserService(_context, _config);
 }
Ejemplo n.º 11
0
        static void Main()
        {
            using DMSContext con = new DMSContext();
            Mapper.Initialize(cfg =>
            {
                cfg.AddProfiles(typeof(DocumentManagement.Automapper.Profiles.ActivityProfile).Assembly);
            });


            ActivityService activityService = new ActivityService(new RabbitMqBus(new DocumentRepository(con)), new DocumentRepository(con));

            ActivityDTO        newActivity     = new ActivityDTO();
            List <DocumentDTO> InputDocuments  = new List <DocumentDTO>();
            List <DocumentDTO> OutputDocuments = new List <DocumentDTO>();

            do
            {
                DocumentDTO d = new DocumentDTO();
                Console.WriteLine("Insert document");
                Console.Write("Type: ");
                d.Type = Console.ReadLine();
                Console.Write("Operation ");
                string operation = Console.ReadLine();

                switch (operation)
                {
                case "Send":
                    d.OutputOperation = OutputOperationsDTO.Send;
                    OutputDocuments.Add(d);
                    break;

                case "Update":
                    d.OutputOperation = OutputOperationsDTO.Update;
                    OutputDocuments.Add(d);
                    break;

                case "Create":
                    d.OutputOperation = OutputOperationsDTO.Create;
                    OutputDocuments.Add(d);
                    break;

                case "Receive":
                    d.InputOperation = InputOperationsDTO.Receive;
                    InputDocuments.Add(d);
                    break;

                case "Request":
                    d.InputOperation = InputOperationsDTO.Request;
                    InputDocuments.Add(d);
                    break;

                default:
                    break;
                }
            } while (Console.ReadKey().Key != ConsoleKey.Escape);
            newActivity.InputDocuments  = InputDocuments;
            newActivity.OutputDocuments = OutputDocuments;
            Console.WriteLine("Binder da?");
            if (Console.ReadLine() == "da")
            {
                activityService.AddBinder(new Binder {
                    InititatorType = "Narudzbenica", Outputs = new Dictionary <string, STATE> {
                        { "Narudzbenica", STATE.CHANGED }
                    }
                });
            }
            activityService.SaveActivity(newActivity);
            Console.WriteLine("Activity created!");

            //make binder



            Console.WriteLine("Create new operation?");
            Console.ReadKey();
            OperationDTO opDTO = activityService.LoadOperation();

            Console.WriteLine("Received");

            opDTO.Received?.ToList().ForEach(item => {
                Console.WriteLine(item.Type + " " + item.File.Name + " " + item.Id);
            });


            Console.WriteLine("Requested");
            opDTO.Requested?.ToList().ForEach(item => {
                Console.WriteLine(item.Type + " " + item.File.Name + " " + item.Id);
                Console.Write("Id: ");
                string id = Console.ReadLine();
                item.Id   = Int32.Parse(id);
            });
            Console.WriteLine("Output");
            opDTO.OutputDocuments?.ToList().ForEach(item => {
                Console.WriteLine(item.Type + " ");
                Console.Write("Id: ");
                string id = Console.ReadLine();
                item.Id   = int.Parse(id);
            });

            activityService.SaveOperation(opDTO);


            #region jic

            /*
             * Mapper.Initialize(cfg =>
             * {
             *  cfg.AddProfiles(typeof(DocumentManagement.Automapper.Profiles.ActivityProfile).Assembly);
             * });
             * ActivityService activityService = new ActivityService(new DMBus(new RabbitMqBus()), new DocumentRepository(new DMSContext()));
             * activityService.SaveActivity(new ActivityDTO() { OutputDocuments = new List<DocumentDTO> { new DocumentDTO { OutputOperation = OutputOperationsDTO.Send, Type = "b" }, new DocumentDTO { OutputOperation = OutputOperationsDTO.Create, Type = "c" } } });
             * Console.WriteLine("Activity created!");
             * Document doc = new Document { OutputOperation = OutputOperations.Send, Type = "b", Id = 1 };
             * doc.File.File = File.ReadAllBytes(Path.GetFullPath(@"file\mean.txt"));
             * doc.File.Name = "mean.txt";
             * doc.Id = 123456789;
             * Console.WriteLine("Operation!");
             * activityService.SaveOperation(new OperationDTO {
             *  OutputDocuments=new List<DocumentDTO>() {
             *      new DocumentDTO{ OutputOperation = OutputOperationsDTO.Send, Type = "b", Id = 2, File = new FileWrapperDTO{ Name = "FileName2", File = doc.File.File } },
             *      new DocumentDTO{ OutputOperation = OutputOperationsDTO.Send, Type = "b", Id = 3, File = new FileWrapperDTO{ Name = "FileName3", File = doc.File.File } },
             *      new DocumentDTO{ OutputOperation = OutputOperationsDTO.Send, Type = "b", Id = 4, File = new FileWrapperDTO{ Name = "FileName4", File = doc.File.File } },
             *      new DocumentDTO{ OutputOperation = OutputOperationsDTO.Send, Type = "e", Id = 33, File = new FileWrapperDTO{ Name = "FileName3", File = doc.File.File } },
             *      new DocumentDTO{ OutputOperation = OutputOperationsDTO.Send, Type = "e", Id = 34, File = new FileWrapperDTO{ Name = "FileName4", File = doc.File.File } },
             *      new DocumentDTO{ OutputOperation = OutputOperationsDTO.Create, Type = "c", Id = 5, File = new FileWrapperDTO{ Name = "FileName5", File = doc.File.File } },
             *      new DocumentDTO{ OutputOperation = OutputOperationsDTO.Create, Type = "c", Id = 6, File = new FileWrapperDTO{ Name = "FileName6", File = doc.File.File } },
             *  }
             *
             *
             * });
             *
             */
            #endregion



            #region

            /*
             *
             *
             *  //DMBus mb = new DMBus(new DocumentManagement.Messaging.RabbitMqBus());
             * //mb.Start(new Models.Activity() { OutputDocuments = new List<Document> { new Document { OutputOperation = OutputOperations.Send, Type = "b" }, new Document { OutputOperation = OutputOperations.Create, Type = "c" } } });
             *
             * //Document doc = new Document { OutputOperation = OutputOperations.Send, Type = "b", Id = 1 };
             * //doc.File.File = File.ReadAllBytes(Path.GetFullPath(@"file\mean.txt"));
             * //doc.File.Name = "mean.txt";
             * //mb.SendDocument(doc);
             * //doc.Id = 123456789;
             * //mb.SendDocument(new Document { OutputOperation = OutputOperations.Send, Type = "b", Id = 2 });
             * //mb.SendDocument(new Document { OutputOperation = OutputOperations.Send, Type = "b", Id = 3 });
             *
             * //mb.SendDocument(new Document { OutputOperation = OutputOperations.Create, Type = "b", Id = 11 });
             * //mb.SendDocument(new Document { OutputOperation = OutputOperations.Create, Type = "b", Id = 12 });
             * //mb.SendDocument(new Document { OutputOperation = OutputOperations.Create, Type = "b", Id = 13 });
             */
            #endregion
            Console.WriteLine("Kraj!");
            Console.ReadLine();
        }
Ejemplo n.º 12
0
 public ReportsService(DMSContext context, IHostingEnvironment hostingEnvironment)
 {
     _hostingEnvironment = hostingEnvironment;
     _context            = context;
 }
Ejemplo n.º 13
0
 public UserController(DMSContext _context)
 {
     _user = new UserService(_context);
 }
Ejemplo n.º 14
0
 public HomeController(DMSContext context, IHostingEnvironment hostingEnvironment)
 {
     _categoryService = new CategoryService(context);
     _reportsService  = new ReportsService(context, hostingEnvironment);
 }
Ejemplo n.º 15
0
 public DocumentService(DMSContext db)
 {
     _context = db;
 }
Ejemplo n.º 16
0
 public CategoryService(DMSContext db)
 {
     _context = db;
 }
Ejemplo n.º 17
0
 public DocumentService(DMSContext db, IHostingEnvironment appEnvironment)
 {
     _context        = db;
     _appEnvironment = appEnvironment;
 }
Ejemplo n.º 18
0
 public UserService(DMSContext context, IConfiguration config)
 {
     _context = context;
     _config  = config;
 }
Ejemplo n.º 19
0
 public AuthService(DMSContext db)
 {
     _context = db;
 }
Ejemplo n.º 20
0
 public DeliveriesController(DMSContext context)
 {
     _context = context;
 }
Ejemplo n.º 21
0
 public AuthController(DMSContext context)
 {
     _authService = new AuthService(context);
 }
Ejemplo n.º 22
0
 public CreateAdmin(RoleManager <IdentityRole> roleManager, UserManager <User> userManager, DMSContext context)
 {
     _roleManager = roleManager;
     _userManager = userManager;
     _context     = context;
 }