Exemplo n.º 1
0
        public async Task <ActionResult> Login(LoginViewModel model, string returnUrl)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var user = await UserManager.FindAsync(model.UserName, model.Password);

                    if (user != null)
                    {
                        await SignInAsync(user, model.RememberMe);

                        return(RedirectToLocal(returnUrl));
                    }
                    else
                    {
                        ModelState.AddModelError("", "Invalid username or password.");
                    }
                }
            }
            catch (Exception ex)
            {
                ILoggerService.AddLogger("Account-Create", ex.ToString());
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
Exemplo n.º 2
0
        //public CategoryController(ICategoryService Icat, ILoggerService ILS)
        //{
        //    ICategoryService = Icat;
        //    ILoggerService = ILS;
        //}

        #region Action Methods

        // GET: /Category/
        public ActionResult Index()
        {
            try
            {
                string connectString = System.Configuration.ConfigurationManager.ConnectionStrings["StoreDBConnectionString"].ToString();

                List <CategoryModel> model = null;

                using (LinqToSQLDataContextDataContext context = new LinqToSQLDataContextDataContext(connectString))
                {
                    IEnumerable <LinqToSQLClasses.Category> cat = context.Categories.ToList();
                    Mapper.CreateMap <LinqToSQLClasses.Category, CategoryModel>();
                    model = Mapper.Map <IEnumerable <LinqToSQLClasses.Category>, List <CategoryModel> >(cat);
                }

                //IEnumerable<Category> cat = ICategoryService.CategoryList();
                //Mapper.CreateMap<Category, CategoryModel>();
                //IEnumerable<CategoryModel> model = Mapper.Map<IEnumerable<Category>, IEnumerable<CategoryModel>>(cat);

                return(View(model));
            }
            catch (Exception ex)
            {
                ILoggerService.AddLogger("CategoryController-Index", ex.ToString());
                return(View());
            }
        }
        // GET: /Product/
        public ActionResult Index()
        {
            try
            {
                IEnumerable <Product> ProductList = IProductService.UserProductsList(User.Identity.GetUserId());
                Mapper.CreateMap <Product, ProductModel>().ForMember(m => m.CategoryName, opt => opt.MapFrom(p => p.Category.Name));
                IEnumerable <ProductModel> model = Mapper.Map <IEnumerable <Product>, IEnumerable <ProductModel> >(ProductList);

                return(View(model.ToList()));
            }
            catch (Exception ex)
            {
                ILoggerService.AddLogger("ProductController-Index", ex.ToString());
                return(View());
            }
        }