Esempio n. 1
0
 public DestructionController()
 {
     _db         = new DistilDBContext();
     _dl         = new DataLayer(_db);
     _purchase   = new PurchaseWorkflow(_db, _dl);
     _production = new ProductionWorkflow(_db, _dl);
 }
Esempio 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);
 }
Esempio 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);
                    }
                }
            }
        }
 public DeveloperController()
 {
     _db = new DistilDBContext();
     _dl = new DataLayer(_db);
 }
Esempio n. 5
0
 public ReportRepository(DistilDBContext context, DataLayer dl)
 {
     _context = context;
     _dl      = dl;
 }
 public DictionaryWorkflow(DistilDBContext db, DataLayer dl)
 {
     _db = db;
     _dl = dl;
 }
Esempio n. 7
0
 public DictionaryController()
 {
     _db         = new DistilDBContext();
     _dl         = new DataLayer(_db);
     _dictionary = new DictionaryWorkflow(_db, _dl);
 }
Esempio n. 8
0
 public PurchaseController()
 {
     _db       = new DistilDBContext();
     _dl       = new DataLayer(_db);
     _purchase = new PurchaseWorkflow(_db, _dl);
 }
Esempio n. 9
0
 public PurchaseWorkflow(DistilDBContext db, DataLayer dl)
 {
     _db = db;
     _dl = dl;
 }
Esempio n. 10
0
 public AccountController()
 {
     _db = new DistilDBContext();
 }