public bool AddProfile(ProfileViewModel profileViewModel) { try { using (var db = new OnlineStoreMVCEntities()) { var profile = new system_Profiles { UserId = profileViewModel.UserId, UserName = profileViewModel.UserName, Emaill = profileViewModel.Emaill, Password = profileViewModel.Password, Phone = profileViewModel.Phone, Address = profileViewModel.Address }; db.system_Profiles.Add(profile); db.SaveChanges(); return(true); } } catch (Exception ex) { throw ex; } }
public ActionResult Edit([Bind(Include = "UserId,UserName,Emaill,Password,Phone,Address")] system_Profiles system_profiles) { if (ModelState.IsValid) { //db.Entry(system_profiles).State = EntityState.Modified; //db.SaveChanges(); return(RedirectToAction("Index")); } return(View(system_profiles)); }
/// <summary> /// Get information of a brand /// </summary> /// <param name="id">id of brand</param> /// <returns>return a view model to display on client side</returns> public Model.ViewModel.DetailsBrandManagementView GetDetailBrand(int id) { ecom_Brands brand = db.GetByID(id); if (brand == null) { throw new ArgumentNullException(); } // Get user create brand and user last time modified brand system_Profiles createBy = systemProfiles.GetByID(brand.CreatedBy); system_Profiles modifiredBy = systemProfiles.GetByID(brand.CreatedBy); return brand.ConvertToDetailsBrandView(createBy != null ? createBy.UserName : "", modifiredBy != null ? modifiredBy.UserName : ""); }
public ActionResult Create([Bind(Include = "UserId,UserName,Emaill,Password,Phone,Address")] system_Profiles system_profiles) { if (ModelState.IsValid) { //system_profiles.UserId = Guid.NewGuid(); //db.system_Profiles.Add(system_profiles); //db.SaveChanges(); return(RedirectToAction("Index")); } return(View(system_profiles)); }
/// <summary> /// Get detail category after id /// </summary> /// <param name="id"></param> /// <returns></returns> public DetailCategoryViewModel GetDetailCategory(int id) { string parentCategory = ""; ecom_Categories category = db.GetByID(id); if (category == null) { return(null); } else { // Get user create brand and user last time modified brand system_Profiles createBy = systemProfiles.GetByID(category.CreatedBy); system_Profiles modifiredBy = systemProfiles.GetByID(category.CreatedBy); // get parent category if (category.ParentId != null) { ecom_Categories parent = db.GetByID(category.ParentId); parentCategory = parent != null ? parent.Name : ""; } return(category.ConvertToDetailCategoryViewModel(parentCategory, createBy, modifiredBy)); } }
public static DetailCategoryViewModel ConvertToDetailCategoryViewModel(this ecom_Categories category, string parentName, system_Profiles createBy, system_Profiles modifiredBy) { DetailCategoryViewModel detailCategory = new DetailCategoryViewModel() { Id = category.Id, ParentId= category.ParentId, Name = category.Name, ParentCategory = parentName, Description = category.Description, Url = category.Url, SortOrder = category.SortOrder, Status = EnumHelper.GetDescriptionFromEnum((Define.Status)category.Status), CreatedBy = createBy!=null?createBy.UserName:"", CreatedDate = string.Format("{0:yyyy-MM-dd}", category.CreatedDate), ModifiedBy = modifiredBy != null ? createBy.UserName : "", ModifiedDate = string.Format("{0:yyyy-MM-dd}", category.ModifiedDate) }; return detailCategory; }