コード例 #1
0
ファイル: PostService.cs プロジェクト: enesusanmaz/Arc
 public PostService(UnitofWork uow)
 {
     _uow                = uow;
     _postRepository     = uow.GetRepository <Post>();
     _userRepository     = uow.GetRepository <User>();
     _categoryRepository = uow.GetRepository <Category>();
 }
コード例 #2
0
        // GET: Customer
        public ActionResult Index()
        {
            using (var tx = uow.BeginTransaction())
            {
                var listitem = uow.GetRepository <Customer>().All().ToList();

                return(View(listitem));
            }
        }
コード例 #3
0
 public ActionResult ListByCat(int id, int page = 1)
 {
     using (UnitofWork uow = new UnitofWork())
     {
         return(View(uow.GetRepository <Product>().Listele().Where(x => x.CategoryID == id).ToPagedList(page, 9)));
     }
 }
コード例 #4
0
        public override void OnAuthorization(AuthorizationContext filterContext)
        {
            bool       authorized = false;
            UnitofWork uow        = new UnitofWork();
            AppUser    user       = uow.GetRepository <AppUser>().Listele().First(x => x.UserName == HttpContext.Current.User.Identity.Name);

            string userRole = Enum.GetName(typeof(Role), user.Role);

            foreach (var role in this.UserProfilesRequired)
            {
                if (userRole == role)
                {
                    authorized = true;
                    break;
                }
            }

            if (!authorized)
            {
                var url      = new UrlHelper(filterContext.RequestContext);
                var logonUrl = url.Action("Http", "Error", new { Id = 401, Area = "" });
                filterContext.Result = new RedirectResult(logonUrl);
            }
            base.OnAuthorization(filterContext);
        }
コード例 #5
0
 public ActionResult Update(int id)
 {
     using (UnitofWork uow = new UnitofWork())
     {
         Category c = uow.GetRepository <Category>().GetElementById(id);
         return(View(c));
     }
 }
コード例 #6
0
        public ActionResult Order(Order o)
        {
            var           odt = Session["od"] as Order_Details;
            Order_Details od  = new Order_Details();

            od       = odt;
            od.Order = o;
            o.Order_Details.Add(od);
            using (UnitofWork uow = new UnitofWork())
            {
                uow.GetRepository <Order>().Ekle(o);
                uow.GetRepository <Order_Details>().Ekle(od);
                uow.SaveChanges();
            }
            Response.Write("<script>alert('Bizi Tercih Ettiğiniz İçin Teşekkür Ederiz')</script>");
            return(Redirect("/Home/Index"));
        }
コード例 #7
0
 public ActionResult List()
 {
     using (UnitofWork uow = new UnitofWork())
     {
         var list = uow.GetRepository <Category>().Listele();
         return(View(list));
     }
 }
コード例 #8
0
 public ActionResult Delete(int id)
 {
     using (UnitofWork uow = new UnitofWork())
     {
         uow.GetRepository <Category>().Sil(id);
         uow.SaveChanges();
     }
     return(Redirect("/Admin/Category/List"));
 }
コード例 #9
0
 public ActionResult Update(Category c)
 {
     using (UnitofWork uow = new UnitofWork())
     {
         uow.GetRepository <Category>().Guncelle(c);
         uow.SaveChanges();
     }
     return(Redirect("/Admin/Category/List"));
 }
コード例 #10
0
        public ActionResult Login(AppUser a)
        {
            AppUser data = uow.GetRepository <AppUser>().Listele().First(x => x.UserName == a.UserName && x.Password == a.Password);

            if (data != null)
            {
                FormsAuthentication.SetAuthCookie(data.UserName, true);
                HttpCookie usercookie = new HttpCookie("user", data.UserName.ToString());
                usercookie.Expires.AddMinutes(20);
                Response.Cookies.Add(usercookie);

                return(Redirect("/Home/Index"));
            }
            else
            {
                return(Redirect("/Home/Index"));
            }
        }
コード例 #11
0
        public ActionResult OrderCart(Order o)
        {
            List <Order_Details> odlist = Session["odlist"] as List <Order_Details>;

            foreach (var item in odlist)
            {
                item.Order = o;
                o.Order_Details.Add(item);
            }
            using (UnitofWork uow = new UnitofWork())
            {
                foreach (var item in odlist)
                {
                    uow.GetRepository <Order_Details>().Ekle(item);
                }
                uow.GetRepository <Order>().Ekle(o);
            }
            Response.Write("<script>alert('Bizi Tercih Ettiğiniz İçin Teşekkür Ederiz')</script>");
            return(View("/Home/Index"));
        }
コード例 #12
0
 public JsonResult Search(string a)
 {
     using (UnitofWork uow = new UnitofWork())
     {
         var list = uow.GetRepository <Product>().Listele().Where(x => x.ProductName.ToLower().StartsWith(a) || x.ProductName.ToLower().Contains(a)).Select(x => new Product
         {
             ID          = x.ID,
             ImagePath   = x.ImagePath,
             ProductName = x.ProductName
         });
         return(Json(list, JsonRequestBehavior.AllowGet));
     }
 }
コード例 #13
0
        public JsonResult SiparisTasarimSonucu(string dt)
        {
            using (UnitofWork uow = new UnitofWork())
            {
                var urun = uow.GetRepository <Product>().Listele().Select(x => new Product {
                    ID          = x.ID,
                    ImagePath   = x.ImagePath,
                    ProductName = x.ProductName
                }).First(x => x.ProductName == dt);


                return(Json(urun, JsonRequestBehavior.AllowGet));
            }
        }
コード例 #14
0
        public ActionResult Order(int id)
        {
            Order_Details od = new Order_Details();

            using (UnitofWork uow = new UnitofWork())
            {
                var urun = uow.GetRepository <Product>().GetElementById(id);
                od.ProductName = urun.ProductName;
                od.ProductID   = urun.ID;
                od.Quantity++;
                od.UnitPrice = urun.Price;
                Session.Add("od", od);
            }
            return(View());
        }
コード例 #15
0
 public CategoryService(UnitofWork uow)
 {
     _uow = uow;
     _categoryRepository = uow.GetRepository <Category>();
     //_postRepository = uow.GetRepository<Post>();
 }
コード例 #16
0
        public ActionResult Add()
        {
            var list = uow.GetRepository <Category>().Listele();

            return(View(list));
        }
コード例 #17
0
 public ActionResult List()
 {
     var list = uow.GetRepository<Order>().Listele();
     return View(list);
 }
コード例 #18
0
        public ActionResult Index(int page = 1)
        {
            var list = uow.GetRepository <Product>().Listele();

            return(View(list.OrderBy(x => x.ProductName).ToPagedList(page, 16)));
        }