Exemple #1
0
        public UserViewModel Get(string id)
        {
            var user = dbContext.AspNetUsers.Find(id);

            if (user == null)
            {
                return(null);
            }
            if (user.AspNetUserRoles.Count == 0)
            {
                var role = dbContext.AspNetRoles.ToList().Find(x => x.Name == "User");
                user.AspNetUserRoles.Add(new AspNetUserRoles {
                    UserId = user.Id, RoleId = role.Id
                });
                dbContext.SaveChanges();
            }
            var userViewModel = new UserViewModel
            {
                Id        = user.Id,
                Name      = user.UserName,
                Image     = user.Image,
                Biography = user.Biography,
                Country   = user.Country,
                Role      = user.AspNetUserRoles.FirstOrDefault(x => x.UserId == user.Id).Role.Name
            };

            return(userViewModel);
        }
Exemple #2
0
        public ActionResult Create([Bind(Include = "Id,City,StreetName,WorkTime,OnlineOrder")] Shop shop)
        {
            if (ModelState.IsValid)
            {
                db.CamShop.Add(shop);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(shop));
        }
Exemple #3
0
        public ActionResult Create([Bind(Include = "Id,Name")] City city)
        {
            if (ModelState.IsValid)
            {
                db.Cities.Add(city);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(city));
        }
        public ActionResult Create([Bind(Include = "Id,Type,Bedrooms,Rooms,Area,Floor,ResidentialDistrict,City,Price,Year,Extras")] Property property)
        {
            if (ModelState.IsValid)
            {
                db.Properties.Add(property);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(property));
        }
Exemple #5
0
 public void Saved()
 {
     ctx.SaveChanges();
 }
 public void Create(T item)
 {
     Context.Set <T>().Add(item);
     Context.SaveChanges();
 }
 public virtual int SaveChanges() => context.SaveChanges();