public void CreateUserInProduct(AdminUserManagementModel.CreateAdminAspUser model) { Core_UserProducts obj = new Core_UserProducts { ProductId = model.ProductId, UserId = model.UserAppId, }; ent.AddToCore_UserProducts(obj); ent.SaveChanges(); }
public void CheckExistanceofUserProduct(int UserId, int productid) { TravelPortalEntity.EntityModel ent = new TravelPortalEntity.EntityModel(); var product = ent.Core_UserProducts.Where(xx => xx.UserId == UserId && xx.ProductId == productid).ToList(); if (product.Count() == 0) { Core_UserProducts obj = new Core_UserProducts { ProductId = productid, UserId = UserId, }; ent.AddToCore_UserProducts(obj); ent.SaveChanges(); } }
public ActionResult Delete(Guid id) { try { TravelPortalEntity.EntityModel ent = new EntityModel(); UsersDetails userDetails = ent.UsersDetails.Where(x => x.UserId == id).FirstOrDefault(); List <Core_UserProducts> userprod = ent.Core_UserProducts.Where(x => x.UserId == userDetails.AppUserId).ToList(); if (userprod != null) { foreach (var item in userprod) { Core_UserProducts data = item; if (data != null) { ent.DeleteObject(data); ent.SaveChanges(); } } } if (userDetails != null) { ent.DeleteObject(userDetails); ent.SaveChanges(); } List <LoginHistories> loginResult = ent.LoginHistories.Where(x => x.UserId == id).ToList(); foreach (var item in loginResult) { LoginHistories rec = item; ent.DeleteObject(rec); ent.SaveChanges(); } aspnet_Users user = ent.aspnet_Users.Where(x => x.UserId == id).FirstOrDefault(); Membership.DeleteUser(user.UserName, true); } catch { } return(RedirectToAction("Index")); }
public void AddUserProduct(List <int> Productidlist, int userid) { try { int count = Productidlist.Count; List <Core_UserProducts> Lists = new List <Core_UserProducts>(); for (int i = 0; i < count; i++) { Core_UserProducts Productlist = new Core_UserProducts(); Productlist.UserId = userid; Productlist.ProductId = Productidlist[i]; Lists.Add(Productlist); } SaveUserProduct(Lists); } catch (Exception ex) { throw new Exception(ex.Message); } }