Example #1
1
        public async Task SetupAsync()
        {
            _evnt = new EventViewModel
            {
                Title = "Title event",
                Description = "Test event",
                Start = "11:00",
                End = "14:27",
                Date = "2016-02-01"
            };

            var userViewModel = new LoginViewModel
            {
                Email = "*****@*****.**",
                Password = "******",
                RememberMe = false
            };
            var context = new DataContext();
            var manager = new UserManager(new UserStore(context));
            var user = await manager.FindAsync(userViewModel.Email, userViewModel.Password);
            if (user == null)
            {
                await manager.CreateAsync(new User { Email = userViewModel.Email, UserName = userViewModel.Email }, userViewModel.Password);
            }
            _calendarController = new CalendarController(context);

            var mockCp = new Mock<IClaimsPrincipal>();
            if (user != null) mockCp.SetupGet(cp => cp.UserId).Returns(user.Id);
            _calendarController.CurrentUser = mockCp.Object;

            var mockAuthenticationManager = new Mock<IAuthenticationManager>();
            mockAuthenticationManager.Setup(am => am.SignOut());
            mockAuthenticationManager.Setup(am => am.SignIn());
            _calendarController.AuthenticationManager = mockAuthenticationManager.Object;
        }
        //cambBuscar
        //*creavuelo
        public Vuelo buscarporId(int idVuelo)
        {
            Vuelo vuelo = new Vuelo();
            MyConnection myConnection = new MyConnection();

            DataContext datacontext = new DataContext(myConnection.SQLConnection);

            var Table = datacontext.GetTable<Vuelo>();

            try
            {
                var buscarPorIdVuelo = from vueloId in Table
                                       where vueloId.IdVuelo == idVuelo
                                       select vueloId;
                foreach (Vuelo v in buscarPorIdVuelo)
                {
                    vuelo = v;
                }

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            return vuelo;
        }
Example #3
0
        public int LinkInsert(DataContext Context)
        {
            var Links = Context.GetTable<CRdsAttributeLink>();
            Links.InsertOnSubmit(this);

            return -1;
        }
Example #4
0
        /// <summary>
        /// Metoda zapisująca informacje o użytkowniku
        /// </summary>
        /// <param name="email"></param>
        /// <param name="result"></param>
        /// <returns></returns>
        public bool SaveUser(string email, Users result)
        {
            try
            {
                using (var context = new DataContext())
                {
                    var user = context.Table<Users>().NewQuery().FirstOrDefault(x => x.Email == email);
                    if (user != null)
                    {
                        user.Name = result.Name;
                        user.Surname = result.Surname;
                        if (!string.IsNullOrEmpty(result.Password))
                        {
                            user.Password = result.Password;
                        }

                        context.Table<Users>().Update(user);
                        context.SaveChanges();

                        return true;
                    }
                }
            }
            catch (Exception ex)
            {
                // ojojojoj
            }

            return false;
        }
        public void Test2()
        {
            var dc = new DataContext();
            dc.AddTable("data", new[] {
                new Item { Col1="A", Col2 = 2 }
            });

            var flow = new Flow { Orientation = FlowOrientation.Vertical };
            var table = flow.AddTable<Item>("data");
            table.Columns.Single(a => a.DataField == "Col2").ConditionalFormatting = (value) => {
                if (!(value is int))
                    return null;
                var v = (int)value;
                if (v > 0)
                    return new Styling.CellStyle
                    {
                        FontStyle = new Styling.FontStyle
                        {
                            FontColor = Styling.Color.FromHtml("#00FF00")
                        }
                    };
                return null;
            };

            var rep = Report.CreateReport(flow, dc);
            var cells = ReportUtil.GetCellMatrix(rep);

            Assert.IsNull(cells[0][0].CustomStyle);
            Assert.IsNotNull(cells[0][1].CustomStyle);

            var html = HtmlReportWriter.RenderReport(rep, new DefaultHtmlReportTheme());
            Assert.IsTrue(html.Contains("style=\"color:"));
            Assert.IsTrue(html.Contains("#00FF00"));
        }
        public void DataObjectQuery_Should_Select_All_Items_From_Database_With_Parameter_Binding_And_Context_Transaction()
        {
            commandMock.Setup(c => c.CommandText).Returns("SELECT [Id], [Name], [FirstFlight] FROM Airplane WHERE Name = @Name");

            using (var context = new DataContext())
            {
                // Execute a command to open transaction.
                context.Execute("DELETE FROM Airplane");

                // Simulate connection open state later the first execute.
                connectionMock.Setup(c => c.State).Returns(ConnectionState.Open);

                select.With(context).All("WHERE Name = @Name", new { Name = "Omega" });

                context.Commit();
            }

            connectionMock.Verify(c => c.CreateCommand(), Times.Exactly(2));
            connectionMock.Verify(c => c.Open(), Times.Once());
            connectionMock.Verify(c => c.BeginTransaction(), Times.Once());
            connectionMock.Verify(c => c.Close(), Times.Once());
            commandMock.Verify(c => c.ExecuteReader(), Times.Once());
            commandMock.VerifySet(c => c.CommandText = "SELECT [Id], [Name], [FirstFlight] FROM Airplane WHERE Name = @Name");
            commandMock.VerifySet(c => c.Connection = connectionMock.Object);
            commandMock.VerifySet(c => c.Transaction = transactionMock.Object);
            commandMock.Verify(c => c.CreateParameter(), Times.Once());
            parameterMock.VerifySet(p => p.ParameterName = "@Name");
            parameterMock.VerifySet(p => p.Value = "Omega");
            parameterCollectionMock.Verify(p => p.Add(parameterMock.Object), Times.Once());
            transactionMock.Verify(t => t.Commit(), Times.Once());
        }
 public void InitDatabase()
 {
     using (Db = new DataContext())
     {
         Db.InitilizeDatabase();
     }
 }
Example #8
0
 /// <summary>
 /// Metoda pobierająca id użytkownika na podstawie jego maila
 /// </summary>
 /// <param name="email"></param>
 /// <returns></returns>
 public int GetUserId(string email)
 {
     using (var context = new DataContext())
     {
         return context.Table<Users>().NewQuery().Where(x => x.Email == email).Select(x => x.ID).FirstOrDefault();
     }
 }
 private void DropDatabase()
 {
     using (var data = new DataContext("Master", Transaction.No))
     {
         data.Execute("DROP DATABASE ThunderTest");
     }
 }
 public override bool DeleteRole(string roleName, bool throwOnPopulatedRole)
 {
     if (string.IsNullOrEmpty(roleName))
     {
         return false;
     }
     using (DataContext Context = new DataContext())
     {
         Role Role = null;
         Role = Context.Roles.FirstOrDefault(Rl => Rl.RoleName == roleName);
         if (Role == null)
         {
             return false;
         }
         if (throwOnPopulatedRole)
         {
             if (Role.Users.Any())
             {
                 return false;
             }
         }
         else
         {
             Role.Users.Clear();
         }
         Context.Roles.Remove(Role);
         Context.SaveChanges();
         return true;
     }
 }
 private void CreateDatabase()
 {
     using (var data = new DataContext("Master", Transaction.No))
     {
         data.Execute("CREATE DATABASE ThunderTest");
     }
 }
        private void CreateTables()
        {
            var createManufacturerTable = new StringBuilder("CREATE TABLE Le_Manufacturer (")
                .Append("[TheId] NUMERIC(8) NOT NULL IDENTITY PRIMARY KEY,")
                .Append("[Name] VARCHAR(32) NOT NULL,")
                .Append("[BuildYear] NUMERIC(4) NOT NULL)")
                .ToString();

            var createCarTable = new StringBuilder("CREATE TABLE Car (")
                .Append("[Id] NUMERIC(8) NOT NULL IDENTITY PRIMARY KEY,")
                .Append("[Name] VARCHAR(32) NOT NULL,")
                .Append("[ModelYear] NUMERIC(4) NOT NULL,")
                .Append("[Date] DATETIME NOT NULL,")
                .Append("[Chassis] VARCHAR(32) NOT NULL,")
                .Append("[Mileage] FLOAT,")
                .Append("[ManufacturerId] NUMERIC(8) REFERENCES Le_Manufacturer(TheId))")
                .ToString();

            using (var data = new DataContext())
            {
                data.Execute(createManufacturerTable);
                data.Execute(createCarTable);
                data.Commit();
            }
        }
 public ManageEventCategoriesViewModel()
 {
     using (DataContext context = new DataContext())
     {
         EventCategories = context.EventCategories.ToList();
     }
 }
Example #14
0
 public static void CloseConnection()
 {
     _context.Connection.Close();
     _context.Dispose();
     _table = null;
     _context = null;
 }
        public JsonResult AddCategory(string name)
        {
            var result = new JsonResult();

            if (!String.IsNullOrEmpty(name))
            {
                using (var context = new DataContext())
                {
                    var newCategory = new BlogCategory
                    {
                        CategoryName = name,
                        CreateDate = DateTime.Now,
                        IsActive = true
                    };

                    context.BlogCategories.Add(newCategory);
                    context.SaveChanges();

                    result.Data = new {id = newCategory.CategoryId};

                    return result;
                }
            }

            return result;
        }
        public BlogsByUserViewModel(string username)
        {
            // Get back to the original name before url conversion
            BlogUsername = username.Replace(ContentGlobals.BLOGDELIMMETER, " ");

            using (var context = new DataContext())
            {

                // Get User based on authorid
                TheBlogUser = context.BlogUsers.FirstOrDefault(x => x.Username == BlogUsername);

                MaxBlogCount = BlogListModel.GetBlogSettings().MaxBlogsOnHomepageBeforeLoad;
                BlogTitle = BlogListModel.GetBlogSettings().BlogTitle;

                BlogsByUser = context.Blogs.Where(x => x.Author == BlogUsername && x.IsActive)
                            .OrderByDescending(blog => blog.Date)
                            .Take(MaxBlogCount)
                            .ToList();

                // Try permalink first
                TheBlog = BlogsByUser.FirstOrDefault(x => x.Author == BlogUsername);

                if (BlogsByUser.Count > 0)
                {
                    LastBlogId = BlogsByUser.LastOrDefault().BlogId;
                }
            }
        }
        /// <summary>
        /// Constructor initializes DataContext 
        /// plus adds additional configuration
        /// </summary>
        public RepositoryBase()
        {
            dc = new DataContext();

            dc.Configuration.LazyLoadingEnabled = false;
            dc.Configuration.ProxyCreationEnabled = false;
        }
Example #18
0
        static void Main(string[] args)
        {
            DataContext dc = new DataContext(@"Data Source=.\SQLEXPRESS;Initial Catalog=AdventureWorks;Integrated Security=True");

            dc.Log = Console.Out;

            //Table<Pessoa> pessoas = dc.GetTable<Pessoa>();

            var pessoas = from p in dc.GetTable<Pessoa>()
                          select p;

            //ObjectDumper.Write(pessoas);

            //Console.WriteLine();

            var nomes = from p in pessoas
                        select p.Nome;

            nomes = from p in nomes
                    where p.Equals("ABEL")
                    select p;

            ObjectDumper.Write(nomes);

            Console.ReadKey();
        }
        public AuthorizationRepository()
        {
            _dataContext = new DataContext();
            var userStore = new UserStore<PropertyManagerUser>(_dataContext);
            _userManager = new UserManager<PropertyManagerUser>(userStore);

        }
Example #20
0
        public async Task<ActionResult> Login(LoginViewModel model, string returnUrl)
        {
            if (!ModelState.IsValid)
            {
                using (var db = new DataContext())
                {
                    ViewBag.LoginsList = db.Users.ToArray();
                }

                return View(model);
            }

            // This doesn't count login failures towards account lockout
            // To enable password failures to trigger account lockout, change to shouldLockout: true
            var result = await SignInManager.PasswordSignInAsync(model.UserName, model.Password, model.RememberMe, shouldLockout: false);
            switch (result)
            {
                case SignInStatus.Success:
                    return RedirectToLocal(returnUrl);
                case SignInStatus.LockedOut:
                    return View("Lockout");
                case SignInStatus.RequiresVerification:
                    return RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = model.RememberMe });
                case SignInStatus.Failure:
                default:
                    ModelState.AddModelError("", "Invalid login attempt.");
                    return View(model);
            }
        }
        public EventCategorySingleViewModel(string category, HttpServerUtilityBase server)
        {
            _server = server;

            category = formatCategoryString(category);

            //ImageList = getImageList();

            using (var context = new DataContext())
            {
                var tomorrow = DateTime.Now.Date;
                TheCategory = context.EventCategories.FirstOrDefault(x => x.CategoryName == category);

                EventRoll = context.Events.Where(x => x.MainCategory == category && x.IsActive == true && DateTime.Compare(x.EndDate.Value, tomorrow) >= 0).ToList();

                // Set a random picture on the eventRoll if none is currently set
                //foreach (var event in EventRoll)
                //{
                //	if (String.IsNullOrEmpty(event.ImageUrl))
                //	{
                //		event.ImageUrl = getRandomImage();
                //	}

                //}
            }
        }
Example #22
0
        public void TestContext(string context)
        {
            var ctx = new DataContext(context);

            ctx.GetTable<Person>().ToList();

            ctx.KeepConnectionAlive = true;

            ctx.GetTable<Person>().ToList();
            ctx.GetTable<Person>().ToList();

            ctx.KeepConnectionAlive = false;

            using (var tran = new DataContextTransaction(ctx))
            {
                ctx.GetTable<Person>().ToList();

                tran.BeginTransaction();

                ctx.GetTable<Person>().ToList();
                ctx.GetTable<Person>().ToList();

                tran.CommitTransaction();
            }
        }
Example #23
0
        public CMetaobjectExtented(Guid ID, DataContext Context)
            : base(ID, Context)
        {
            this._likesNumberAttribute.Attributes = this._attributes;

            this.LikesNumber = 0;
        }
Example #24
0
        /// <summary>
        /// Creates a new site tree model for the given namespace.
        /// </summary>
        /// <param name="id">Namespace id</param>
        public SiteTreeEditModel(Guid namespaceId)
        {
            // Get the namespaces
            using (var db = new DataContext()) {
                var ns = db.Namespaces.OrderBy(n => n.Name).ToList() ;
                if (namespaceId != Guid.Empty)
                    Namespaces = new SelectList(ns, "Id", "Name", namespaceId) ;
                Namespaces = new SelectList(ns, "Id", "Name") ;
            }

            // Get the available region types
            RegionTypes = new List<dynamic>() ;
            ExtensionManager.Extensions.Where(e => e.ExtensionType == ExtensionType.Region).OrderBy(e => e.Name).Each((i, r) =>
                RegionTypes.Add(new { Name = r.Name, Type = r.Type.ToString() })) ;
            RegionTypes.Insert(0, new { Name = "", Type = "" }) ;

            // Initialize the new site
            Id = Guid.NewGuid() ;
            NamespaceId = namespaceId ;
            Template = new PageTemplate() {
                Id = Id,
                Name = Id.ToString(),
                IsSiteTemplate = true
            } ;
            Regions = Template.RegionTemplates ;
        }
        public int AmountInsert(DataContext Context)
        {
            var Amounts = Context.GetTable<CMenuServiceOrderAmount>();
            Amounts.InsertOnSubmit(this);

            return CErrors.ERR_SUC;
        }
Example #26
0
        public CMetaobjectExtented(decimal Key, DataContext Context)
            : base(Key, Context)
        {
            this._likesNumberAttribute.Attributes = this._attributes;

            this.LikesNumber = 0;
        }
        //private static TextWriter dbLinqLogWriter = new StreamWriter(@"C:\Temp\sipsorcery\dblinq.log", true, Encoding.ASCII);

        public static DataContext CreateDBLinqDataContext(StorageTypes storageType, string connectionString) {
            DataContext dataContext = null;
            //DbProviderFactory factory = DbProviderFactories.GetFactory(providerName);
            //new MySql.Data.MySqlClient.MySqlClientFactory();
            //DbProviderFactory factory = Npgsql.NpgsqlFactory.Instance;
            
            switch (storageType) {
                case StorageTypes.DBLinqMySQL:
                    IDbConnection mySqlConn = new MySqlConnection(connectionString);
                    dataContext = new DataContext(mySqlConn, m_mappingSource, new DbLinq.MySql.MySqlVendor());
                    break;
                case StorageTypes.DBLinqPostgresql:
                    IDbConnection npgsqlConn = new NpgsqlConnection(connectionString);
                    dataContext = new DataContext(npgsqlConn, m_mappingSource, new DbLinq.PostgreSql.PgsqlVendor());
                    break;
                default:
                    throw new NotSupportedException("Database type " + storageType + " is not supported by CreateDBLinqDataContext.");
            }

            //dataContext.QueryCacheEnabled = true;
            //dataContext.Log = Console.Out;
            //dataContext.Log = dbLinqLogWriter;
            dataContext.ObjectTrackingEnabled = false;
            return dataContext;
        }
Example #28
0
        private void AddOrUpdate(List<ExcelDeltaker> deltakere, DataContext context)
        {
            var alleLag = context.Lag.ToList();

            foreach (var excelDeltaker in deltakere)
            {
                var deltaker = context.Deltakere.SingleOrDefault(x => x.Kode == excelDeltaker.Kode);

                var lag = alleLag.SingleOrDefault(x => x.LagId == excelDeltaker.LagId);

                if (deltaker == null)
                {
                    context.Deltakere.Add(new Deltaker
                    {
                        DeltakerId = Guid.NewGuid().ToString(),
                        Navn = excelDeltaker.Navn,
                        Kode = excelDeltaker.Kode,
                        Lag = lag
                    });
                }
                else
                {
                    deltaker.Navn = excelDeltaker.Navn;
                    deltaker.Lag = lag;
                }
            }
        }
Example #29
0
		public void Cleanup() {
			DataBoss = null;
			Context.Dispose();
			Context = null;
			Connection.Dispose();
			Connection = null;
		}
Example #30
0
 public RequestHandler(DataContext context, IMapper mapper)
 {
     this.context = context;
     this.mapper  = mapper;
 }
Example #31
0
 public Handler(DataContext context, UserManager <AppUser> userManager, IJwtGenerator jwtGenerator)
 {
     _context      = context;
     _userManager  = userManager;
     _jwtGenerator = jwtGenerator;
 }
Example #32
0
 public DataContext Init()
 {
     return(dbContext ?? (dbContext = new DataContext()));
 }
Example #33
0
 public Handler(DataContext context, IMapper mapper, IUserAccessor userAccessor)
 {
     _context      = context;
     _mapper       = mapper;
     _userAccessor = userAccessor;
 }
 public HardDiskSizeService(DataContext dataContext)
 {
     _context = dataContext;
 }
Example #35
0
 protected Repository(IDatabaseFactory databaseFactory)
 {
     DatabaseFactory = databaseFactory;
     dbset           = DataContext.Set <T>();
 }
Example #36
0
 public ValuesController(DataContext context)
 {
     _context = context;
 }
 public ProductTypeDesignServiceController(DataContext context)
 {
     _context = context;
 }
Example #38
0
 public gastosController(DataContext context)
 {
     _context = context;
 }
Example #39
0
 public Handler(DataContext context, IMapper mapper)
 {
     _mapper  = mapper;
     _context = context;
 }
Example #40
0
 public AttendancesController(DataContext context)
 {
     _context = context;
 }
Example #41
0
 public Handler(DataContext context)
 {
     _context = context;
 }
Example #42
0
 public FuncaoRepository(DataContext context) : base(context)
 {
     this.context = context;
 }
Example #43
0
 public Property(ILogger <Property> logger, DataContext context)
 {
     _logger  = logger;
     _context = context;
 }
Example #44
0
 public AccountController(DataContext context, ITokenService tokenService)
 {
     _context      = context;
     _tokenService = tokenService;
 }
Example #45
0
 public PetTypesController(DataContext context)
 {
     _context = context;
 }
Example #46
0
 public PropertiesController(DataContext dataContext,
                             IConverterHelper converterHelper)
 {
     _dataContext     = dataContext;
     _converterHelper = converterHelper;
 }
Example #47
0
 public StudentController(DataContext ctx)
 {
     _ctx = ctx;
 }
 public GetDiscountQueryHandler(DataContext context, IMapper mapper)
 {
     _context = context;
     _mapper = mapper;
 }
 public CustomerRepository(DataContext context) : base(context)
 {
 }
Example #50
0
 public UserAccessRepository(DataContext dataContext)
 {
     _dataContext = dataContext;
 }
 public Handler(DataContext context, UserManager <AppUser> userManager, IUserAccessor userAccessor)
 {
     _userAccessor = userAccessor;
     _userManager  = userManager;
     _context      = context;
 }
        public ActionResult Edit(Company c, HttpPostedFileBase file)
        {
            bool status=false ;
            User userdata = (User)Session["UserData"];
            Session["UserData"] = userdata;
            Session["UserID"] = userdata.UserId;
          
            ViewBag.ListRecords = GetAllCompany();
            ViewBag.States = new SelectList(stController.GetAllState(), "StateID", "StateName");
            ViewBag.Countries = new SelectList(cnController.GetAllCountry(), "CountryID", "CountryName");

            using (DataContext dc = new DataContext())
            {
                var v = dc.Companies.Where(a => a.CompanyId==c.CompanyId).FirstOrDefault();
                if (v != null)
                {

                    
                    v.CompanyDescription = c.CompanyDescription;
                    v.CompanyLat = c.CompanyLat;
                    v.CompanyLong = c.CompanyLong;
                    v.CompanyAddress = c.CompanyAddress;
                    v.CompanyCity = c.CompanyCity;
                    v.CompanyZipCode = c.CompanyZipCode;
                    v.CompanyTelephoneNo = c.CompanyTelephoneNo;
                    v.DateUpdated=DateTime.Now;

                 
                    if (ModelState.IsValid)
                        {

                            dc.SaveChanges();
                            status = true;
                        }
                        else
                        {

                            status = false;
                            var modelErrors = new List<string>();
                            foreach (var modelState in ModelState.Values)
                            {
                                foreach (var modelError in modelState.Errors)
                                {
                                    modelErrors.Add(modelError.ErrorMessage);
                                }
                            }
                        }
                    }
                else
                    status = false;

            }

            ViewBag.States = new SelectList(stController.GetAllState(), "StateID", "StateName");
            ViewBag.Countries = new SelectList(cnController.GetAllCountry(), "CountryID", "CountryName");
            
            if (status)

                return RedirectToAction("Index");
            else
                return View(c);
        }
Example #53
0
 public Handler(DataContext context)
 {
     this._context = context;
 }
Example #54
0
        public CharacterServices(IMapper mapper, DataContext context)
        {
            _context = context;
            _mapper = mapper;

        }
        public ActionResult Create(Company c)
        {
            string message = "";
            bool status = false;
            int userid = 0;
            userid = Convert.ToInt32(Session["UserID"]);
            User u = (User)Session["UserData"];
            Session["UserData"] = u;
            Session["UserID"] = u.UserId;
            User userdata = (User)Session["UserData"];

                        if (c.CompanyDescription != null)
                                        c.CompanyDescription = "";
                        if (c.CompanyLat == null)
                            c.CompanyLat = 0;
                        if (c.CompanyLong == null)
                            c.CompanyLong = 0;
                        if (c.CompanyAddress == null)
                            c.CompanyAddress = "";
                        if (c.CompanyCity == null)
                            c.CompanyCity = "";
                        if (c.CompanyZipCode == null)
                            c.CompanyZipCode = "";
                        if (c.CompanyTelephoneNo == null)
                            c.CompanyTelephoneNo = "";
                        c.IsActive=true;
                        c.DateUpdated = DateTime.Now;

         
          

            using (DataContext dc = new DataContext())
            {

                
                var v = dc.Companies.Where(a => a.CompanyName.Equals(c.CompanyName)).FirstOrDefault();
                if (v == null)
                {

                    if (ModelState.IsValid)
                    {
                        
                        dc.Companies.Add(c);
                        dc.SaveChanges();
                        status = true;
                    }
                    else
                    {
                        //
                        var modelErrors = new List<string>();
                        foreach (var modelState in ModelState.Values)
                        {
                            foreach (var modelError in modelState.Errors)
                            {
                                modelErrors.Add(modelError.ErrorMessage);
                            }
                        }

                    }
                }
           }
            ViewBag.ListRecords = GetAllCompany();
            ViewBag.States = new SelectList(stController.GetAllState(), "StateID", "StateName");
            ViewBag.Countries = new SelectList(cnController.GetAllCountry(), "CountryID", "CountryName");
            if (status)
                return RedirectToAction("Index");
            else
                return View(c);
        }
Example #56
0
 public TransactionService(DataContext context)
 {
     _context = context;
 }
 public IsHostRequirementHandler(IHttpContextAccessor httpContextAccessor, DataContext context)
 {
     _context             = context;
     _httpContextAccessor = httpContextAccessor;
 }
Example #58
0
 public LiquidacionesController(DataContext context)
 {
     _context            = context;
     _liquidacionService = new LiquidacionService(_context);
 }
Example #59
0
 public AuthRepository(DataContext context)
 {
     this.context = context;
 }
Example #60
-6
        public async Task SetupAsync()
        {
            _userViewModel = new LoginViewModel
            {
                Email = "*****@*****.**",
                Password = "******",
                RememberMe = false
            };
            var context = new DataContext();
            _manager = new UserManager(new UserStore(context));
            _controller = new AccountController(_manager);

            var user = await _manager.FindAsync(_userViewModel.Email, _userViewModel.Password);
            if (user == null)
            {
                await _manager.CreateAsync(new User { Email = _userViewModel.Email, UserName = _userViewModel.Email }, _userViewModel.Password);
            }
            var mockCp = new Mock<IClaimsPrincipal>();
            if (user != null) mockCp.SetupGet(cp => cp.UserId).Returns(user.Id);
            _controller.CurrentUser = mockCp.Object;

            var mockAuthenticationManager = new Mock<IAuthenticationManager>();
            mockAuthenticationManager.Setup(am => am.SignOut());
            mockAuthenticationManager.Setup(am => am.SignIn());
            _controller.AuthenticationManager = mockAuthenticationManager.Object;
        }