Esempio n. 1
0
        public bool AddProgram(string _title)
        {
            var program = new Programs
            {
                Title = _title
            };

            context.Programs.Add(program);
            context.SaveChanges();
            return(true);
        }
Esempio n. 2
0
        public void Create(CityViewModel cityViewModel, string userId)
        {
            var city = new City
            {
                Id   = cityViewModel.Id,
                Name = cityViewModel.Name
            };

            city.CreatedUserId = userId;
            city.CreatedDate   = DateTime.Now;

            _context.Cities.Add(city);
            _context.SaveChanges();
        }
Esempio n. 3
0
        public ActionResult UpdateRole(User u)
        {
            var user = _context.Users.Where(r => r.EmpCode == u.EmpCode);

            //user.Admin = u.Admin;

            //user.SubAdmin = u.SubAdmin;

            //user.PIC = u.PIC;

            //user.ITT_TM = u.ITT_TM;

            //user.SMT_TM = u.SMT_TM;

            //user.FST_TM = u.FST_TM;

            //user.PIC_TM = u.PIC_TM;

            //user.Group_Leader = u.Group_Leader;

            //user.Guard = u.Guard;

            //user.Read_Only = u.Read_Only;

            _context.SaveChanges();

            return(Content("Success"));
        }
Esempio n. 4
0
        public override void Create(TownshipViewModel viewModel, string userId)
        {
            var newTownship = new Township
            {
                Id     = viewModel.Id,
                Name   = viewModel.Name,
                CityId = viewModel.CityId
            };

            newTownship.CreatedDate   = newTownship.UpdatedDate = DateTime.Now; //multi variable assignment
            newTownship.CreatedUserId = newTownship.UpdatedUserId = userId;
            newTownship.Version       = 1;

            _context.Townships.Add(newTownship);
            _context.SaveChanges();
        }
Esempio n. 5
0
        //public static ProductRepository Instance
        //{
        //    get
        //    {
        //        if (ProductRepositoryInstance == null)  ProductRepositoryInstance = new ProductRepository() ;

        //        return ProductRepositoryInstance;
        //    }
        //}
        //private static ProductRepository ProductRepositoryInstance { get; set; }

        //private ProductRepository() { }

        #endregion

        public bool Add(Product product)
        {
            using (var context = new SMSDbContext())
            {
                context.Products.Add(product);
                return(context.SaveChanges() > 0);
            }
        }
Esempio n. 6
0
 public bool Add(Customer customer)
 {
     using (var context = new SMSDbContext())
     {
         context.Customers.Add(customer);
         return(context.SaveChanges() > 0);
     }
 }
Esempio n. 7
0
 public bool Add(Sale sale)
 {
     using (var context = new SMSDbContext())
     {
         context.Sales.Add(sale);
         return(context.SaveChanges() > 0);
     }
 }
Esempio n. 8
0
 public bool Add(Purchase purchase)
 {
     using (var context = new SMSDbContext())
     {
         context.Purchases.Add(purchase);
         return(context.SaveChanges() > 0);
     }
 }
 public bool Add(Category category)
 {
     using (var context = new SMSDbContext())
     {
         context.Categories.Add(category);
         return(context.SaveChanges() > 0);
     }
 }
 public bool Add(Supplier supplier)
 {
     using (var context = new SMSDbContext())
     {
         context.Suppliers.Add(supplier);
         return(context.SaveChanges() > 0);
     }
 }
 public bool Delete(int id)
 {
     using (var context = new SMSDbContext())
     {
         Supplier supplier = context.Suppliers.Find(id);
         context.Suppliers.Remove(supplier);
         return(context.SaveChanges() > 0);
     }
 }
Esempio n. 12
0
 public bool Delete(int id)
 {
     using (var context = new SMSDbContext())
     {
         Product product = context.Products.Find(id);
         context.Products.Remove(product);
         return(context.SaveChanges() > 0);
     }
 }
Esempio n. 13
0
 public bool Delete(int id)
 {
     using (var context = new SMSDbContext())
     {
         Customer customer = context.Customers.Find(id);
         context.Customers.Remove(customer);
         return(context.SaveChanges() > 0);
     }
 }
 public bool Delete(int id)
 {
     using (var context = new SMSDbContext())
     {
         Category category = context.Categories.Find(id);
         context.Categories.Remove(category);
         return(context.SaveChanges() > 0);
     }
 }
Esempio n. 15
0
        public override void Create(BranchViewModel viewModel, string userId)
        {
            var branch = new Branch
            {
                Id          = viewModel.Id,
                Name        = viewModel.Name,
                CityId      = viewModel.CityId,
                TownshipId  = viewModel.TownshipId,
                FullAddress = viewModel.FullAddress,
                PhoneNo     = viewModel.PhoneNo,
                Email       = viewModel.Email,
                Version     = 1
            };

            branch.CreatedUserId = branch.UpdatedUserId = userId;
            branch.CreatedDate   = branch.UpdatedDate = DateTime.Now;

            _context.Branches.Add(branch);
            _context.SaveChanges();
        }
Esempio n. 16
0
        public ActionResult Cancel(int id)
        {
            var bringout = dbContext.Bring_Out.FirstOrDefault(t => t.ID == id);

            bringout.Cancel = true;

            dbContext.SaveChanges();

            return(Content("Success"));
        }
Esempio n. 17
0
        public ActionResult Create(Guest m)
        {
            var guest = Request.Form.Get("guest");
            var model = JsonConvert.DeserializeObject <Guest>(guest);

            //file
            if (Request.Files.Count > 0)
            {
                var file     = Request.Files.Get("file");
                var fileName = Path.GetFileName(file.FileName);
                model.FileRedirectURL = fileName;

                if (!Directory.Exists(Server.MapPath("~/Files")))
                {
                    Directory.CreateDirectory(Server.MapPath("~/Files"));
                }
                var filePath = Server.MapPath("~/Files/" + fileName);
                file.SaveAs(filePath);
            }

            string json = Newtonsoft.Json.JsonConvert.SerializeObject(model);

            var guests = new List <Guest>();

            saveGuest(FormatDate(model.EstimatedDateIn), FormatDate(model.EstimatedDateOut), json, ref guests);

            dbContext.Guests.AddRange(guests);

            dbContext.SaveChanges();

            return(Content("Success"));
        }
Esempio n. 18
0
        private void SaveError(string message, string stackTrace, string method, string table)
        {
            SMSDbContext _dbContext = new SMSDbContext();
            ErrorLog     _error     = new ErrorLog()
            {
                Message    = message,
                DateLog    = DateTime.Now,
                StackTrace = stackTrace,
                Method     = method,
                Table      = table
            };

            _dbContext.Set <ErrorLog>().Add(_error);
            _dbContext.SaveChanges();
        }
        public bool Update(Category category)
        {
            using (var context = new SMSDbContext())
            {
                Category model = new Category();
                model = context.Categories.Find(category.Id);
                if (model != null)
                {
                    model.Id = category.Id;

                    model.Code = category.Code;
                    model.Name = category.Name;
                }

                return(context.SaveChanges() > 0);
            }
        }
Esempio n. 20
0
        public ActionResult UpdateRoles(string empCode, int[] roles)
        {
            var user          = _context.Users.Single(u => u.EmpCode == empCode);
            var prevUserRoles = _context.UserRoles.Where(ur => ur.UserID == user.ID).ToList();

            _context.UserRoles.RemoveRange(prevUserRoles);
            foreach (var role in roles)
            {
                _context.UserRoles.Add(new UserRole()
                {
                    UserID = user.ID, RoleID = role
                });
            }

            _context.SaveChanges();

            return(Content("OK"));
        }
Esempio n. 21
0
        public ActionResult Create(Bring_In model)
        {
            if (!ModelState.IsValid)
            {
                return(Content("Dữ liệu nhập vào không đúng"));
            }

            model.CreatedDate = DateTime.Now;
            var user = (UserLogin)Session[CommonConstants.USER_SESSION];

            model.CreatedBy = user.EmpCode + "|" + user.FullName;
            model.Status    = false;

            var bringIn = dbContext.Bring_In.Add(model);

            dbContext.SaveChanges();
            return(Content("Success"));
        }
        public bool Update(Customer customer)
        {
            using (var context = new SMSDbContext())
            {
                Customer model = new Customer();
                model = context.Customers.Find(customer.Id);
                if (model != null)
                {
                    model.Id           = customer.Id;
                    model.Code         = customer.Code;
                    model.Name         = customer.Name;
                    model.Address      = customer.Address;
                    model.Email        = customer.Email;
                    model.Contact      = customer.Contact;
                    model.LoyaltyPoint = customer.LoyaltyPoint;
                }

                return(context.SaveChanges() > 0);
            }
        }
Esempio n. 23
0
        public bool Update(Product product)
        {
            using (var context = new SMSDbContext())
            {
                Product model = new Product();
                model = context.Products.Find(product.Id);

                if (model != null)
                {
                    model.Id            = product.Id;
                    model.CategoryId    = product.CategoryId;
                    model.Code          = product.Code;
                    model.Name          = product.Name;
                    model.RecorderLevel = product.RecorderLevel;
                    model.Description   = product.Description;
                }


                return(context.SaveChanges() > 0);
                //return true;
            }
        }
        public ApiResult AddService([FromUri] long id, [FromBody] ServicePackageModel.ServicesModel model)
        {
            var package = db.ServicePackages.SingleOrDefault(m => m.Id == id);

            if (package == null)
            {
                return(ApiResult.Fail("找不到要修改套餐"));
            }
            if (package.Services.Any(a => a.ServiceId == model.ServiceId))
            {
                return(ApiResult.Fail("服务已经存在请先删除"));
            }
            package.Services.Add(new R_ServiceDescription_ServicePackage
            {
                PackageId      = id,
                Price          = model.Price,
                SequenceNumber = model.SequenceNumber,
                ServiceId      = model.ServiceId
            });
            db.SaveChanges();
            return(ApiResult.Ok());
        }
        public bool Update(Supplier supplier)
        {
            using (var context = new SMSDbContext())
            {
                Supplier model = new Supplier();
                model = context.Suppliers.Find(supplier.Id);

                if (model != null)
                {
                    model.Id            = supplier.Id;
                    model.Code          = supplier.Code;
                    model.Name          = supplier.Name;
                    model.Address       = supplier.Address;
                    model.Email         = supplier.Email;
                    model.Contact       = supplier.Contact;
                    model.ContactPerson = supplier.ContactPerson;
                }


                return(context.SaveChanges() > 0);
                //return true;
            }
        }
 public bool AddCourse(Course _course)
 {
     context.Courses.Add(_course);
     context.SaveChanges();
     return(true);
 }
Esempio n. 27
0
 public bool AddUser(RegisterUser _registerUser)
 {
     context.RegisterUsers.Add(_registerUser);
     context.SaveChanges();
     return(true);
 }
 public bool AddStudent(MorningStudent _morningStudent)
 {
     context.MorningStudents.Add(_morningStudent);
     context.SaveChanges();
     return(true);
 }
Esempio n. 29
0
        public ActionResult ApproveGoOut(int id, string remark, int status)
        {
            var data = dbcontext.Go_Out.Find(id);
            var user = (UserLogin)Session[CommonConstants.USER_SESSION];

            data.GuardOut       = user.EmpCode + " | " + user.FullName;
            data.GuardStatusOut = status;
            data.GuardRemarkOut = remark;
            data.GuardDateOut   = DateTime.Now;

            dbcontext.SaveChanges();
            return(Content(JsonConvert.SerializeObject(data), "application/json"));
        }
 public bool AddMarksEntry(MarksEntry _marksEntry)
 {
     context.MarksEntries.Add(_marksEntry);
     context.SaveChanges();
     return(true);
 }