예제 #1
0
 public ActionResult ViewCourse(int?id)
 {
     DAL.Entities           DC = new DAL.Entities();
     StarDev.Models.Courses _m = new Models.Courses();
     _m.ShowCourse = DC.ViewCourse.Where(x => x.ShowCourseID == id).ToList();
     return(View(_m));
 }
예제 #2
0
        public async Task <ActionResult> RenderImage(int id)
        {
            DAL.Entities DC   = new DAL.Entities();
            DAL.Image    item = await DC.Image.FindAsync(id);

            byte[] photoBack = item.File;
            return(File(photoBack, "image/jpeg"));
        }
        public QueryObject InsertOrder(Order order)
        {
            const string Sql = @"insert into [dbo].[Orders]
                                       ([CustomerID]
                                       ,[EmployeeID]
                                       ,[OrderDate]
                                       ,[RequiredDate]
                                       ,[ShippedDate]
                                       ,[ShipVia]
                                       ,[Freight]
                                       ,[ShipName]
                                       ,[ShipAddress]
                                       ,[ShipCity]
                                       ,[ShipRegion]
                                       ,[ShipPostalCode]
                                       ,[ShipCountry])
                                 values
                                      (@CustomerID,
                                       @EmployeeID,
                                       @OrderDate,
                                       @RequiredDate,
                                       @ShippedDate,
                                       @ShipVia,
                                       @Freight,
                                       @ShipName,
                                       @ShipAddress,
                                       @ShipCity,
                                       @ShipRegion,
                                       @ShipPostalCode,
                                       @ShipCountry);
                                select scope_identity()";

            var parameters = new
            {
                order.CustomerID,
                order.EmployeeID,
                order.OrderDate,
                order.RequiredDate,
                order.ShippedDate,
                order.ShipVia,
                order.Freight,
                order.ShipName,
                order.ShipAddress,
                order.ShipCity,
                order.ShipRegion,
                order.ShipPostalCode,
                order.ShipCountry
            };

            return new QueryObject(Sql, parameters);
        }
예제 #4
0
        public ActionResult SaveImages(string Title, HttpPostedFileBase file)

        {
            DAL.Entities         DC              = new DAL.Entities();
            System.Drawing.Image sourceimage     = System.Drawing.Image.FromStream(file.InputStream);
            ImageConverter       _imageConverter = new ImageConverter();

            byte[]    xByte = (byte[])_imageConverter.ConvertTo(sourceimage, typeof(byte[]));
            DAL.Image _img  = new DAL.Image();
            _img.Title = Title;
            _img.File  = xByte;
            DC.Image.Add(_img);
            DC.SaveChanges();
            return(RedirectToAction("Index", "Images"));
        }
예제 #5
0
        public ActionResult Courses(int page = 1)
        {
            DAL.Entities           DC = new DAL.Entities();
            StarDev.Models.Courses _m = new Models.Courses();
            int TotalCount            = DC.Courses.Count();
            int PageItem = 6;
            int skip     = (page - 1) * PageItem;

            ViewBag.pageId    = page;
            ViewBag.pageCount = (TotalCount / PageItem);
            if (TotalCount % PageItem != 0)
            {
                ViewBag.PageCount = (TotalCount / PageItem) + 1;
            }
            _m.GetAllCourse = DC.Courses.OrderBy(x => x.CourseID).Skip(skip).Take(PageItem).ToList();
            return(View(_m));
        }
예제 #6
0
        public ActionResult Course(string name)
        {
            DAL.Entities           DC = new DAL.Entities();
            StarDev.Models.Courses _m = new Models.Courses();
            var q = (from A in DC.Courses
                     where
                     (!string.IsNullOrEmpty(name) ? A.Title.Contains(name) || A.content.Contains(name) : true)
                     select A).ToList();

            _m.GetAllCourse = q;

            if (q.Count > 0)
            {
                return(View(_m));
            }
            else
            {
                return(RedirectToAction("NotFound", "Home"));
            }
        }
        public QueryObject UpdateOrder(Order order)
        {
            const string Sql = @"update [dbo].[Orders]
                                   set [CustomerID] = @CustomerID
                                      ,[EmployeeID] = @EmployeeID
                                      ,[OrderDate] = @OrderDate
                                      ,[RequiredDate] = @RequiredDate
                                      ,[ShippedDate] = @ShippedDate
                                      ,[ShipVia] = @ShipVia
                                      ,[Freight] = @Freight
                                      ,[ShipName] = @ShipName
                                      ,[ShipAddress] = @ShipAddress
                                      ,[ShipCity] = @ShipCity
                                      ,[ShipRegion] = @ShipRegion
                                      ,[ShipPostalCode] = @ShipPostalCode
                                      ,[ShipCountry] = @ShipCountry
                                 where
                                    OrderID = @OrderID

                                select @@ROWCOUNT";

            var parameters = new
            {
                order.CustomerID,
                order.EmployeeID,
                order.OrderDate,
                order.RequiredDate,
                order.ShippedDate,
                order.ShipVia,
                order.Freight,
                order.ShipName,
                order.ShipAddress,
                order.ShipCity,
                order.ShipRegion,
                order.ShipPostalCode,
                order.ShipCountry,
                order.OrderID
            };

            return new QueryObject(Sql, parameters);
        }