/// <summary> /// Create a new Designer object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="name">Initial value of the Name property.</param> /// <param name="designerName">Initial value of the DesignerName property.</param> /// <param name="designerNameF">Initial value of the DesignerNameF property.</param> /// <param name="imageSource">Initial value of the ImageSource property.</param> public static Designer CreateDesigner(global::System.Int32 id, global::System.String name, global::System.String designerName, global::System.String designerNameF, global::System.String imageSource) { Designer designer = new Designer(); designer.Id = id; designer.Name = name; designer.DesignerName = designerName; designer.DesignerNameF = designerNameF; designer.ImageSource = imageSource; return designer; }
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"); }
/// <summary> /// Deprecated Method for adding a new object to the Designer EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToDesigner(Designer designer) { base.AddObject("Designer", designer); }
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 }); } }