예제 #1
0
        /// <summary>
        /// 新增数据
        /// </summary>
        /// <param name="entity">实体</param>
        /// <returns></returns>
        public TEntity Add(TEntity entity)
        {
            var result = DbSet.Add(entity).Entity;

            dbContext.SaveChanges();
            return(result);
        }
        public int SaveRoles(VMRoleMaster roleMaster, int UserID)
        {
            if (_context.RoleMasters.Where(u => u.RoleId == roleMaster.RoleId).FirstOrDefault() == null)
            {
                RoleMaster role = new RoleMaster();
                role.RoleName    = roleMaster.RoleName;
                role.CreatedBy   = UserID;
                role.CreatedTime = DateTime.Now;
                role.UpdatedBy   = null;
                role.UpdatedTime = null;
                _context.RoleMasters.Add(role);
                _context.SaveChanges();

                int         roleId   = role.RoleId;
                ActivityLog activity = new ActivityLog();
                activity.ActivityType = "created";
                activity.ActivityFor  = "Role";
                _logRepository.SetActivityLog(activity, roleId, UserID);
            }
            else
            {
                var data = _context.RoleMasters.FirstOrDefault(u => u.RoleId == roleMaster.RoleId);
                data.RoleName    = roleMaster.RoleName;
                data.UpdatedTime = DateTime.Now;
                data.UpdatedBy   = UserID;
                _context.RoleMasters.Update(data);
                _context.SaveChanges();

                ActivityLog activity = new ActivityLog();
                activity.ActivityType = "updated";
                activity.ActivityFor  = "Role";
                _logRepository.SetActivityLog(activity, data.RoleId, UserID);
            }
            return(1);
        }
예제 #3
0
        public async Task <IActionResult> CreateComment(string Yorum, int id)
        {
            var user = await _userManager.GetUserAsync(User);

            var restaurant = _context.Restaurant.FirstOrDefault(f => f.RestaurantId == id);

            if (restaurant != null)
            {
                if (!String.IsNullOrEmpty(Yorum))
                {
                    Comment newComment = new Comment();
                    newComment.Restaurant = restaurant;
                    newComment.Text       = Yorum;
                    newComment.UserId     = user.Id;
                    newComment.UserName   = user.UserName;
                    _context.Comment.Add(newComment);
                    _context.SaveChanges();
                }
            }
            TempData["StatusMessage"] = JsonConvert.SerializeObject(new StatusMessageViewModel
            {
                Type     = StatusMessageType.Success,
                Category = StatusMessageCategory.User,
                Date     = DateTime.Now,
                Message  = "Yorumunuz başarıyla eklendi."
            });
            return(RedirectToAction("Detail", new { id = id }));
        }
예제 #4
0
        private void CreateHostRoleAndUsers()
        {
            //Admin role for host

            var adminRoleForHost = _context.Roles.FirstOrDefault(r => r.TenantId == null && r.Name == StaticRoleNames.Host.Admin);

            if (adminRoleForHost == null)
            {
                adminRoleForHost = _context.Roles.Add(new Role {
                    Name = StaticRoleNames.Host.Admin, DisplayName = StaticRoleNames.Host.Admin, IsStatic = true
                });
                _context.SaveChanges();

                //Grant all tenant permissions
                var permissions = PermissionFinder
                                  .GetAllPermissions(new WebAuthorizationProvider())
                                  .Where(p => p.MultiTenancySides.HasFlag(MultiTenancySides.Host))
                                  .ToList();

                foreach (var permission in permissions)
                {
                    _context.Permissions.Add(
                        new RolePermissionSetting
                    {
                        Name      = permission.Name,
                        IsGranted = true,
                        RoleId    = adminRoleForHost.Id
                    });
                }

                _context.SaveChanges();
            }

            //Admin user for tenancy host

            var adminUserForHost = _context.Users.FirstOrDefault(u => u.TenantId == null && u.UserName == User.AdminUserName);

            if (adminUserForHost == null)
            {
                adminUserForHost = _context.Users.Add(
                    new User
                {
                    UserName         = User.AdminUserName,
                    Name             = "System",
                    Surname          = "Administrator",
                    EmailAddress     = "*****@*****.**",
                    IsEmailConfirmed = true,
                    Password         = new PasswordHasher().HashPassword(User.DefaultPassword)
                });

                _context.SaveChanges();

                _context.UserRoles.Add(new UserRole(null, adminUserForHost.Id, adminRoleForHost.Id));

                _context.SaveChanges();
            }
        }
예제 #5
0
        public int Add(SeasonViewModel vm)
        {
            var p = new Season();

            p.Name = vm.Name;
            var a = _context.Seasons.Add(p);

            _context.SaveChanges();
            return(a.Entity.Id);
        }
예제 #6
0
 public ActionResult Edit(User user)
 {
     if (ModelState.IsValid)
     {
         db.Entry(user).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index", "people"));
     }
     return(View(user));
 }
        public ActionResult Create([Bind(Include = "MaHeDaoTao,TenHeDaoTao")] HeDaoTao heDaoTao)
        {
            if (ModelState.IsValid)
            {
                db.HeDaoTaos.Add(heDaoTao);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(heDaoTao));
        }
예제 #8
0
        public ActionResult Create([Bind(Include = "id,fullname,address,phoneNumber")] EMPLOYER eMPLOYER)
        {
            if (ModelState.IsValid)
            {
                db.EMPLOYERs.Add(eMPLOYER);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(eMPLOYER));
        }
예제 #9
0
        public ActionResult Create([Bind(Include = "PositionId,PositionCode,PositionName,AllowanceRate")] Position position)
        {
            if (ModelState.IsValid)
            {
                db.Positions.Add(position);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(position));
        }
예제 #10
0
        public ActionResult Create([Bind(Include = "Id,X,Y,Support,Confidence")] Luat luat)
        {
            if (ModelState.IsValid)
            {
                db.Luats.Add(luat);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(luat));
        }
예제 #11
0
        public int Add(SubViewModel s)
        {
            var p = new Sub();

            p.Name   = s.Name;
            p.Status = true;
            var a = _context.Subs.Add(p);

            _context.SaveChanges();
            return(a.Entity.Id);
        }
        public ActionResult Create([Bind(Include = "DXT_ID,DiemToan,DiemVan,DiemLy,DiemHoa,DiemSinh,DiemDia,DiemGDCD,DiemNN,HinhThucXetTuyen")] DiemXetTuyen diemXetTuyen)
        {
            if (ModelState.IsValid)
            {
                db.DiemXetTuyens.Add(diemXetTuyen);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(diemXetTuyen));
        }
        public AnimeCategoryViewModel Add(AnimeCategoryViewModel vm)
        {
            AnimeCategory p = new AnimeCategory();

            p.CategoryId = vm.CategoryId;
            p.AnimeId    = vm.AnimeId;
            var a = _context.AnimeCategorys.Add(p);

            _context.SaveChanges();
            return(vm);
        }
        public ActionResult Create([Bind(Include = "MaMon,TenMon,TichLuy,DiemDat")] MonHoc monHoc)
        {
            if (ModelState.IsValid)
            {
                db.MonHocs.Add(monHoc);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(monHoc));
        }
        public ActionResult Create([Bind(Include = "MaToHop,Mon1,Mon2,Mon3")] ToHopMon toHopMon)
        {
            if (ModelState.IsValid)
            {
                db.ToHopMons.Add(toHopMon);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(toHopMon));
        }
예제 #16
0
        public ActionResult Create([Bind(Include = "BusinessId,BusinessName")] WebBusiness webBusiness)
        {
            if (ModelState.IsValid)
            {
                db.Businesses.Add(webBusiness);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(webBusiness));
        }
        public ActionResult Create([Bind(Include = "MaTinh,TenTinh,KhuVuc")] Tinh tinh)
        {
            if (ModelState.IsValid)
            {
                db.Tinhs.Add(tinh);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(tinh));
        }
        public ActionResult Create([Bind(Include = "MaNganh,TeNganh")] NganhTheoBo nganhTheoBo)
        {
            if (ModelState.IsValid)
            {
                db.NganhTheoBos.Add(nganhTheoBo);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(nganhTheoBo));
        }
예제 #19
0
        public ActionResult Create([Bind(Include = "id,name")] TYPEROOM tYPEROOM)
        {
            if (ModelState.IsValid)
            {
                db.TYPEROOMs.Add(tYPEROOM);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(tYPEROOM));
        }
        public ActionResult Create([Bind(Include = "Id,CMND,Khoi,DiemMon1,DiemMon2,DiemMon3")] KhaoSat khaoSat)
        {
            if (ModelState.IsValid)
            {
                db.KhaoSat.Add(khaoSat);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(khaoSat));
        }
예제 #21
0
        public ActionResult Create([Bind(Include = "ID_HocKi,NamHoc,KyHoc")] HocKy hocKy)
        {
            if (ModelState.IsValid)
            {
                db.HocKys.Add(hocKy);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(hocKy));
        }
예제 #22
0
        public ActionResult Create([Bind(Include = "MaKhoaHoc,NamHoc")] KhoaHoc khoaHoc)
        {
            if (ModelState.IsValid)
            {
                db.KhoaHocs.Add(khoaHoc);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(khoaHoc));
        }
        public ActionResult Create([Bind(Include = "MaKhoa,TenKhoa")] Khoa khoa)
        {
            if (ModelState.IsValid)
            {
                db.Khoas.Add(khoa);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(khoa));
        }
예제 #24
0
        public int Add(YearViewModel year)
        {
            var p = new Year();

            p.Name   = year.Name;
            p.Status = true;
            var a = _context.Year.Add(p);

            _context.SaveChanges();
            return(a.Entity.Id);
        }
예제 #25
0
        public int Add(CategoryViewModel vm)
        {
            Catetgory p = new Catetgory();

            p.Name   = vm.Name;
            p.Status = true;
            var a = _context.Catetgories.Add(p);

            _context.SaveChanges();
            return(a.Entity.Id);
        }
예제 #26
0
        public ActionResult Create([Bind(Include = "id,username,password,role")] MANAGER mANAGER)
        {
            if (ModelState.IsValid)
            {
                db.MANAGERs.Add(mANAGER);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(mANAGER));
        }
예제 #27
0
        public ActionResult Create([Bind(Include = "MaChuyenNganh,TenChuyenNganh,MaKhoa")] ChuyenNganh chuyenNganh)
        {
            if (ModelState.IsValid)
            {
                db.ChuyenNganhs.Add(chuyenNganh);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.MaKhoa = new SelectList(db.Khoas, "MaKhoa", "TenKhoa", chuyenNganh.MaKhoa);
            return(View(chuyenNganh));
        }
예제 #28
0
 public ActionResult Add(BookCategoryViewModel model)
 {
     if (ModelState.IsValid)
     {
         var bookCategory = new BookCategory();
         bookCategory.UpdateBookCategory(model);
         _bookCategoryService.Add(bookCategory);
         _context.SaveChanges();
         ViewData["successMsg"] = "Thêm thành công";
     }
     return(View());
 }
예제 #29
0
        public ActionResult Create([Bind(Include = "CategoryId,CategoryName,OrderNo,Status,UserId")] WebCategory webCategory)
        {
            if (ModelState.IsValid)
            {
                db.Categories.Add(webCategory);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.UserId = new SelectList(db.Administrators, "UserId", "UserName", webCategory.UserId);
            return(View(webCategory));
        }
        public ActionResult Create([Bind(Include = "MaTruongTHPT,MaHuyen,MaTinh,TenTruong")] TruongTHPT truongTHPT)
        {
            if (ModelState.IsValid)
            {
                db.TruongTHPTs.Add(truongTHPT);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.MaHuyen = new SelectList(db.Huyens, "MaHuyen", "khuvuc", truongTHPT.MaHuyen);
            return(View(truongTHPT));
        }