Esempio n. 1
0
 public ActionResult Index()
 {
     using (var context = new PortfolioContainer())
     {
         var designers = context.Designer.ToList();
         return View(designers);
     }
 }
Esempio n. 2
0
 public ActionResult Details(string id)
 {
     using (var context = new PortfolioContainer())
     {
         var designer = context.Designer.FirstOrDefault(d => d.Name == id);
         if (designer == null)
             return RedirectToAction("NotFoundPage", "Error",new {area=""});
             //throw new ObjectNotFoundException("designer not found");
         return View(designer);
     }
 }
Esempio n. 3
0
 public ActionResult RoomDetails(string id, int roomType)
 {
     using (var context = new PortfolioContainer())
     {
         var designer = context.Designer.Include("DesignerContents").First(d => d.Name == id);
         ViewBag.RoomType = roomType;
         foreach (var content in designer.DesignerContents.Where(c => c.RoomType == roomType))
         {
             content.DesignerContantImages.Load();
         }
         return View(designer);
     }
 }
Esempio n. 4
0
 public ActionResult Edit(int id)
 {
     using (var context = new PortfolioContainer())
     {
         var designer = context.Designer.First(d => d.Id == id);
         return View(designer);
     }
 }
Esempio n. 5
0
        public ActionResult Create(Designer model, HttpPostedFileBase fileUpload)
        {
            using (var context = new PortfolioContainer())
            {

                string designerId = SiteHelper.UpdatePageWebName(model.Name);


                if (!Roles.RoleExists("Designers"))
                    Roles.CreateRole("Designers");
                if (!Roles.IsUserInRole(designerId, "Designers"))
                    Roles.AddUserToRole(designerId, "Designers");


                FormsAuthentication.SetAuthCookie(designerId, false /* createPersistentCookie */);
                //using (var context = new LibraryContainer())
                //{
                //    var customer = new Customer { Name = model.UserName, Title = model.UserTitle};
                //    context.AddToCustomer(customer);
                //    context.SaveChanges();
                //}

                //return RedirectToAction("Index", "Category", new { area = "FactoryCatalogue" });



                var designer = new Designer
                               {
                                   Name = designerId,
                                   Description = HttpUtility.HtmlDecode(model.Description)
                               };

                TryUpdateModel(designer, new[] { "DesignerName", "DesignerNameF" });


                if (fileUpload != null)
                {
                    string fileName = IOHelper.GetUniqueFileName("~/Content/Images", fileUpload.FileName);
                    string filePath = Server.MapPath("~/Content/Images");
                    filePath = Path.Combine(filePath, fileName);
                    GraphicsHelper.SaveOriginalImage(filePath, fileName, fileUpload, 500);
                    designer.ImageSource = fileName;
                }

                context.AddToDesigner(designer);
                context.SaveChanges();




                MembershipCreateStatus createStatus;
                Membership.CreateUser(designerId, "cde32wsx", designerId, null, null, true, null, out createStatus);

                if (createStatus == MembershipCreateStatus.Success)
                {

                }
            }

            return RedirectToAction("Index");
        }
Esempio n. 6
0
        public ActionResult DeleteImage(int id)
        {
            using (var context = new PortfolioContainer())
            {
                var image = context.DesignerContantImage.Include("DesignerContent").First(i => i.Id == id);
                var dc = context.DesignerContent.Include("Designer").First(d => d.Id == image.DesignerContentId);

                ImageHelper.DeleteImage(image.ImageSource);

                context.DeleteObject(image);
                context.SaveChanges();

                return RedirectToAction("RoomDetails", "Designer", new { area = "DesignersPortfolio", id = dc.Designer.Name, roomType = dc.RoomType });
            }
        }
Esempio n. 7
0
        public ActionResult EditRoom(DesignerContent model)
        {
            using (var context = new PortfolioContainer())
            {
                var dc = context.DesignerContent.Include("Designer").First(d => d.Id == model.Id);

                dc.Description = HttpUtility.HtmlDecode(model.Description);
                dc.RoomTitle = model.RoomTitle;

                for (int i = 0; i < Request.Files.Count; i++)
                {
                    var file = Request.Files[i];

                    if (file == null) continue;
                    if (string.IsNullOrEmpty(file.FileName)) continue;

                    var dci = new DesignerContantImage();
                    string fileName = IOHelper.GetUniqueFileName("~/Content/Images", file.FileName);
                    string filePath = Server.MapPath("~/Content/Images");

                    filePath = Path.Combine(filePath, fileName);
                    GraphicsHelper.SaveOriginalImage(filePath, fileName, file, 1500);

                    dci.ImageSource = fileName;

                    dc.DesignerContantImages.Add(dci);
                }

                context.SaveChanges();

                return RedirectToAction("RoomDetails", "Designer", new { area = "DesignersPortfolio", id = dc.Designer.Name, roomType = dc.RoomType });
            }
        }
Esempio n. 8
0
 public ActionResult EditRoom(int id)
 {
     using (var context = new PortfolioContainer())
     {
         var dc = context.DesignerContent.Include("Designer").First(d => d.Id == id);
         return View(dc);
     }
 }
Esempio n. 9
0
        public ActionResult CreateRoom(int id, int roomType)
        {
            using (var context = new PortfolioContainer())
            {
                var designer = context.Designer.First(d => d.Id == id);

                var dc = new DesignerContent
                         {
                             Designer = designer,
                             RoomType = roomType
                         };

                return View(dc);
            }
        }
Esempio n. 10
0
        public ActionResult Delete(int id)
        {
            using (var context = new PortfolioContainer())
            {




                var designer = context.Designer.Include("DesignerContents").First(d => d.Id == id);
                var designerId = designer.Name;

                while (designer.DesignerContents.Any())
                {
                    var dc = designer.DesignerContents.First();
                    context.DeleteObject(dc);
                }

                ImageHelper.DeleteImage(designer.ImageSource);

                context.DeleteObject(designer);

                context.SaveChanges();


                Membership.DeleteUser(designerId, true);

            }

            return RedirectToAction("Index", "Designer", new { area = "Admin" });
        }
Esempio n. 11
0
        public ActionResult Edit(Designer model, HttpPostedFileBase fileUpload)
        {
            using (var context = new PortfolioContainer())
            {
                var designer = context.Designer.First(d => d.Id == model.Id);
                designer.Name = SiteHelper.UpdatePageWebName(model.Name);
                designer.Description = HttpUtility.HtmlDecode(model.Description);

                TryUpdateModel(designer, new[] { "DesignerName", "DesignerNameF" });

                if (fileUpload != null)
                {
                    if (!string.IsNullOrEmpty(designer.ImageSource))
                    {
                        ImageHelper.DeleteImage(designer.ImageSource);
                    }

                    string fileName = IOHelper.GetUniqueFileName("~/Content/Images", fileUpload.FileName);
                    string filePath = Server.MapPath("~/Content/Images");
                    filePath = Path.Combine(filePath, fileName);
                    GraphicsHelper.SaveOriginalImage(filePath, fileName, fileUpload, 500);
                    designer.ImageSource = fileName;

                }

                context.SaveChanges();

                return RedirectToAction("Details", "Designer", new { area = "DesignersPortfolio", id = designer.Name });
            }
        }