public bool SaveAccomodationType(AccomodationType newRecord)
        {
            db.AccomodationTypes.Add(newRecord);

            return(db.SaveChanges() > 0);
        }
        public bool Add(Supplier supplier)
        {
            _dbContext.Suppliers.Add(supplier);

            return(_dbContext.SaveChanges() > 0);
        }
예제 #3
0
 public bool Add(Product product)
 {
     _dbContext.Products.Add(product);
     return(_dbContext.SaveChanges() > 0);
 }
 public ActionResult Create(Project project)
 {
     database.Projects.Add(project);
     database.SaveChanges();
     return(RedirectToAction(nameof(Index)));
 }
예제 #5
0
 public bool Add(PurchasedProduct purchasedProduct)
 {
     _projectDbContext.PurchasedProducts.Add(purchasedProduct);
     return(_projectDbContext.SaveChanges() > 0);
 }
 public void Add(Slider slider)
 {
     db.Sliders.Add(slider);
     db.SaveChanges();
 }
예제 #7
0
        // public bool Add(SalesDetail salesDetail)
        public bool Add(SalesDetail salesDetail)
        {
            _projectDbContext.SalesDetails.Add(salesDetail);

            return(_projectDbContext.SaveChanges() > 0);
        }
        private void CreateRolesAndUsers()
        {
            //Admin role

            var adminRole = _context.Roles.FirstOrDefault(r => r.TenantId == _tenantId && r.Name == StaticRoleNames.Tenants.Admin);

            if (adminRole == null)
            {
                adminRole = _context.Roles.Add(new Role(_tenantId, StaticRoleNames.Tenants.Admin, StaticRoleNames.Tenants.Admin)
                {
                    IsStatic = true
                });
                _context.SaveChanges();

                //Grant all permissions to admin role
                var permissions = PermissionFinder
                                  .GetAllPermissions(new AppAuthorizationProvider(false))
                                  .Where(p => p.MultiTenancySides.HasFlag(MultiTenancySides.Tenant))
                                  .ToList();

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

                _context.SaveChanges();
            }

            //User role

            var userRole = _context.Roles.FirstOrDefault(r => r.TenantId == _tenantId && r.Name == StaticRoleNames.Tenants.User);

            if (userRole == null)
            {
                _context.Roles.Add(new Role(_tenantId, StaticRoleNames.Tenants.User, StaticRoleNames.Tenants.User)
                {
                    IsStatic = true, IsDefault = true
                });
                _context.SaveChanges();
            }

            //admin user

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

            if (adminUser == null)
            {
                adminUser = User.CreateTenantAdminUser(_tenantId, "*****@*****.**", "123qwe");
                adminUser.IsEmailConfirmed = true;
                adminUser.ShouldChangePasswordOnNextLogin = true;
                adminUser.IsActive = true;

                _context.Users.Add(adminUser);
                _context.SaveChanges();

                //Assign Admin role to admin user
                _context.UserRoles.Add(new UserRole(_tenantId, adminUser.Id, adminRole.Id));
                _context.SaveChanges();

                //User account of admin user
                if (_tenantId == 1)
                {
                    _context.UserAccounts.Add(new UserAccount
                    {
                        TenantId     = _tenantId,
                        UserId       = adminUser.Id,
                        UserName     = User.AdminUserName,
                        EmailAddress = adminUser.EmailAddress
                    });
                    _context.SaveChanges();
                }
            }
        }
 public void Add(Product product)
 {
     db.Products.Add(product);
     db.SaveChanges();
 }
예제 #10
0
        public bool Add(Sales sales)
        {
            _dbContext.Saleses.Add(sales);

            return(_dbContext.SaveChanges() > 0);
        }
 public bool Add(MajorOfBusiness majorOfBusiness)
 {
     _dbContext.MajorOfBusinesses.Add(majorOfBusiness);
     return(_dbContext.SaveChanges() > 0);
 }
예제 #12
0
 public void Save()
 {
     _context.SaveChanges();
 }
예제 #13
0
 public void Add(DoctorContribution doctorContribution)
 {
     db.DoctorContributions.Add(doctorContribution);
     db.SaveChanges();
 }
예제 #14
0
 public void Delete(VehicleMakeEntity entity)
 {
     context.VehicleMake.Remove(entity);
     context.SaveChanges();
     Console.WriteLine(entity.Make.Name);
 }
예제 #15
0
 public bool Add(Product product)
 {
     db.Products.Add(product);
     return(db.SaveChanges() > 0);
 }
 public Project createProject(Project project)
 {
     _context.Projects.Add(project);
     _context.SaveChanges();
     return(project);
 }
예제 #17
0
 public bool Add(Category category)
 {
     _dbContext.Categories.Add(category);
     return(_dbContext.SaveChanges() > 0);
 }
예제 #18
0
 public void Add(CustomerPayment customerPayment)
 {
     db.CustomerPayments.Add(customerPayment);
     db.SaveChanges();
 }
예제 #19
0
 public ActionResult Add(VmProductAdd model)
 {
     TempData["SuccessMsg"] = "";
     TempData["FailedMsg"]  = "";
     if (ModelState.IsValid)
     {
         try
         {
             if (db.Product.Any(a => a.ProductName == model.ProductName))
             {
                 TempData["FailedMsg"] = "Product Already Exist";
             }
             else if (db.Product.Any(a => a.ProductCode == model.ProductCode))
             {
                 TempData["FailedMsg"] = "Product Code Already Exist";
             }
             else
             {
                 #region Image Upload
                 var uri = Request.Url.Host;
                 System.IO.Directory.CreateDirectory(Server.MapPath("~/Images/Product/" + uri));
                 string path = "";
                 if (model.Image1 != null)
                 {
                     string pic          = System.IO.Path.GetFileName(model.Image1.FileName);
                     string physicalPath =
                         System.IO.Path.Combine(Server.MapPath("~/Images/Product/" + uri), pic);
                     path = "/Images/Product/" + uri + "/" + pic;
                     model.Image1.SaveAs(physicalPath);
                     model.ImageUrl1 = path;
                 }
                 path = "";
                 if (model.Image2 != null)
                 {
                     string pic          = System.IO.Path.GetFileName(model.Image2.FileName);
                     string physicalPath =
                         System.IO.Path.Combine(Server.MapPath("~/Images/Product/" + uri), pic);
                     path = "/Images/Product/" + uri + "/" + pic;
                     model.Image2.SaveAs(physicalPath);
                     model.ImageUrl2 = path;
                 }
                 path = "";
                 if (model.Image3 != null)
                 {
                     string pic          = System.IO.Path.GetFileName(model.Image3.FileName);
                     string physicalPath =
                         System.IO.Path.Combine(Server.MapPath("~/Images/Product/" + uri), pic);
                     path = "/Images/Product/" + uri + "/" + pic;
                     model.Image3.SaveAs(physicalPath);
                     model.ImageUrl3 = path;
                 }
                 #endregion
                 var newData = new Product();
                 newData.BrandId                    = model.BrandId;
                 newData.Description                = model.Description;
                 newData.ModelNo                    = model.ModelNo;
                 newData.ProductCode                = model.ProductCode;
                 newData.ProductHeaderId            = model.ProductHeaderId;
                 newData.ProductName                = model.ProductName;
                 newData.ProductSubCategoryHeaderId = model.ProductSubCategoryHeaderId;
                 newData.Rate      = model.Rate;
                 newData.UnitId    = model.UnitId;
                 newData.ImageUrl3 = model.ImageUrl3;
                 newData.ImageUrl2 = model.ImageUrl2;
                 newData.ImageUrl1 = model.ImageUrl1;
                 db.Product.Add(newData);
                 db.SaveChanges();
                 TempData["SuccessMsg"] = "Product Added Successfully";
                 return(RedirectToAction("Index"));
             }
         }
         catch (Exception e)
         {
             TempData["FailedMsg"] = e.Message;
         }
     }
     else
     {
         TempData["FailedMsg"] = "Failed";
     }
     ViewBag.SubCategoryList = db.ProductSubCategory.AsEnumerable().Select(s => new ProductSubCategory {
         ProductCategoryHeaderId = s.ProductCategoryHeaderId, ProductSubCategoryHeaderId = s.ProductSubCategoryHeaderId, ProductSubCategoryName = s.ProductSubCategoryName
     });
     ViewBag.UnitList = db.FndFlexValueSet.Where(w => w.FlexValueSetShortName == "unit").FirstOrDefault().FndFlexValue.Select(s => new VmSelectList {
         Id = s.FlexValueId, Name = s.FlexValue
     });
     ViewBag.BrandList = db.FndFlexValueSet.Where(w => w.FlexValueSetShortName == "brand").FirstOrDefault().FndFlexValue.Select(s => new VmSelectList {
         Id = s.FlexValueId, Name = s.FlexValue
     });
     ViewBag.CategoryList = db.ProductCategory.Select(s => new VmSelectList {
         Id = s.ProductCategoryHeaderId, Name = s.ProductCategoryName
     });
     return(View(model));
 }
예제 #20
0
 public bool AddminLogin(Admin_Login admin_Login)
 {
     _dbContext.Admin_Logins.Add(admin_Login);
     return(_dbContext.SaveChanges() > 0);
 }
예제 #21
0
 public ActionResult Create(Project project)
 {
     context.Projects.Add(project);
     context.SaveChanges();
     return(RedirectToAction(nameof(Index)));
 }
예제 #22
0
 public void Add(Order order)
 {
     db.Orders.Add(order);
     db.SaveChanges();
 }
예제 #23
0
        public bool Add(Student student)
        {
            _ProjectDbContext.Students.Add(student);

            return(_ProjectDbContext.SaveChanges() > 0);
        }
예제 #24
0
 public void Commit()
 {
     _context.SaveChanges();
 }
예제 #25
0
        public int UpdateMonitor(string key = null, string idSchedule = null, string location = null, string coordinate = null, float speed = -1, int status = -1)
        {
            if (key == null || idSchedule == null || location == null || coordinate == null || speed < 0 || (status != 0 && status != 1))
            {
                return(0);
            }
            if (CheckKey(key))
            {
                try
                {
                    ProjectDbContext dbContext = new ProjectDbContext();

                    int idSche    = dbContext.Schedules.Where(x => x.Code == idSchedule).First().ID;
                    int idCar     = dbContext.Schedules.Where(x => x.Code == idSchedule).First().IDCar;
                    int idStudent = dbContext.Schedules.Where(x => x.Code == idSchedule).First().IDStudent;

                    string numberCar   = dbContext.Cars.SingleOrDefault(x => x.ID == idCar).NumberCar;
                    string studentName = dbContext.Students.SingleOrDefault(x => x.ID == idStudent).Name;

                    // update online
                    if (dbContext.CurrentStates.SingleOrDefault(x => x.carID == numberCar) == null)
                    {
                        CurrentState currentState = new CurrentState();
                        currentState.carID       = numberCar;
                        currentState.state       = status;
                        currentState.studentID   = idStudent;
                        currentState.studentName = studentName;
                        currentState.location    = location;
                        currentState.coordinate  = coordinate;
                        currentState.currentTime = DateTime.Now;
                        dbContext.CurrentStates.Add(currentState);
                        dbContext.SaveChanges();
                    }
                    else
                    {
                        CurrentState currentState = dbContext.CurrentStates.SingleOrDefault(x => x.carID == numberCar);
                        currentState.state       = status;
                        currentState.studentID   = idStudent;
                        currentState.studentName = studentName;
                        currentState.location    = location;
                        currentState.coordinate  = coordinate;
                        currentState.currentTime = DateTime.Now;
                        dbContext.SaveChanges();
                    }

                    // update history
                    History history = new History();
                    history.carID       = numberCar;
                    history.carName     = numberCar;
                    history.studentID   = idStudent;
                    history.studentName = studentName;
                    history.scheduleID  = idSche;
                    history.exactTime   = DateTime.Now;
                    history.location    = location;
                    history.coordinate  = coordinate;
                    history.state       = status;
                    history.speed       = speed;
                    history.day         = DateTime.Now.Day;
                    history.month       = DateTime.Now.Month;
                    history.year        = DateTime.Now.Year;

                    dbContext.Historys.Add(history);
                    dbContext.SaveChanges();

                    return(1);
                }
                catch
                {
                    return(0);
                }
            }
            return(0);
        }
예제 #26
0
        public bool Add(Customer customer)
        {
            _projectDbContext.Customers.Add(customer);

            return(_projectDbContext.SaveChanges() > 0);
        }
 public bool Add(StudentModel student)
 {
     _dbContext.Students.Add(student);
     return(_dbContext.SaveChanges() > 0);
 }
 public void Add(ConsultResult consultResult)
 {
     db.ConsultResults.Add(consultResult);
     db.SaveChanges();
 }
예제 #29
0
 public bool Add(Purchase purchase)
 {
     _dbContext.Purchases.Add(purchase);
     return(_dbContext.SaveChanges() > 0);
 }
예제 #30
0
        public bool Add(Sale sale)
        {
            _projectDbContext.Sales.Add(sale);

            return(_projectDbContext.SaveChanges() > 0);
        }