Exemplo n.º 1
0
 public DestructionController()
 {
     _db         = new DistilDBContext();
     _dl         = new DataLayer(_db);
     _purchase   = new PurchaseWorkflow(_db, _dl);
     _production = new ProductionWorkflow(_db, _dl);
 }
Exemplo n.º 2
0
 public ReportingController()
 {
     _db               = new DistilDBContext();
     _dl               = new DataLayer(_db);
     _productionR      = new ProductionReport(_db, _dl);
     _processingR      = new ProcessingReport(_db, _dl);
     _storageR         = new StorageReport(_db, _dl);
     _reportRepository = new ReportRepository(_db, _dl);
 }
Exemplo n.º 3
0
        /// <summary>
        /// Checks if user doesn't exist, if so, creates a new ApplicationUser
        /// </summary>
        public static async Task CheckCreateUser(DistilDBContext _db, Logger _logger, ApplicationUserManager UserManager, ApplicationUser user, string password, uint distillerId)
        {
            var existingUser = await UserManager.FindByNameAsync(user.UserName);

            if (existingUser == null)
            {
                var userCreationSucceeded = false;
                try
                {
                    var result = await UserManager.CreateAsync(user, password);

                    if (result.Succeeded)
                    {
                        userCreationSucceeded = true;
                    }
                    else
                    {
                        throw new Exception(string.Concat(result.Errors));
                    }
                }
                catch (Exception ex)
                {
                    _logger.Error("Failed to create default admin user: {0}", ex.ToString());
                }

                // Insert into AspNetUserToDistiller only after successfully creating a user
                if (userCreationSucceeded)
                {
                    // Find newly created user
                    var newUser = await UserManager.FindByNameAsync(user.UserName);

                    try
                    {
                        _db.AspNetUserToDistiller.Add(new AspNetUserToDistiller {
                            DistillerID = Convert.ToInt32(distillerId), UserId = newUser.Id
                        });
                        _db.SaveChanges();
                    }
                    catch (Exception ex)
                    {
                        // Something is wrong with the connection to the db, log and attempt to revert user creation
                        _logger.Error("Failed to insert into AspNetUserToDistiller table: \n\t{0}", ex.ToString());
                        await UserManager.DeleteAsync(newUser);
                    }
                }
            }
        }
Exemplo n.º 4
0
 public DeveloperController()
 {
     _db = new DistilDBContext();
     _dl = new DataLayer(_db);
 }
Exemplo n.º 5
0
 public ReportRepository(DistilDBContext context, DataLayer dl)
 {
     _context = context;
     _dl      = dl;
 }
Exemplo n.º 6
0
 public DictionaryWorkflow(DistilDBContext db, DataLayer dl)
 {
     _db = db;
     _dl = dl;
 }
Exemplo n.º 7
0
 public DictionaryController()
 {
     _db         = new DistilDBContext();
     _dl         = new DataLayer(_db);
     _dictionary = new DictionaryWorkflow(_db, _dl);
 }
Exemplo n.º 8
0
 public PurchaseController()
 {
     _db       = new DistilDBContext();
     _dl       = new DataLayer(_db);
     _purchase = new PurchaseWorkflow(_db, _dl);
 }
Exemplo n.º 9
0
 public PurchaseWorkflow(DistilDBContext db, DataLayer dl)
 {
     _db = db;
     _dl = dl;
 }
Exemplo n.º 10
0
 public AccountController()
 {
     _db = new DistilDBContext();
 }