예제 #1
0
        private void FirstStart()
        {
            ModelContainer         cont                   = new ModelContainer();
            BranchRepository       branchRepository       = new BranchRepository(cont);
            CategoryRepository     categoryRepository     = new CategoryRepository(cont);
            CompanyOwnerRepository companyOwnerRepository = new CompanyOwnerRepository(cont);
            PersonRepository       personRepository       = new PersonRepository(cont);
            PositionRepository     positionRepository     = new PositionRepository(cont);
            RoomRepository         roomRepository         = new RoomRepository(cont);
            TableRepository        tableRepository        = new TableRepository(cont);
            ClientRepository       clientRepository       = new ClientRepository(cont);

            if (positionRepository.Positions().Count() == 0)
            {
                positionRepository.AddPosition("Суперпользователь", true, true, true, true, true, true);
            }

            CompanyOwner co = new CompanyOwner();

            if (personRepository.Persones().Count() == 0)
            {
                co = companyOwnerRepository.AddCompanyOwner("Суперпользователь", "", "", "", "", "super", "super".GetHashCode().ToString(), "", "", "",
                                                            positionRepository.GetPositionByName("Суперпользователь"));
            }

            Branch b = new Branch();

            if (branchRepository.Branches().Count() == 0)
            {
                b = branchRepository.AddBranch("", "", DateTime.Now, DateTime.Now, "", "", "", "", "", co, null);
            }

            Room r = new Room();

            if (roomRepository.Rooms().Count() == 0)
            {
                r = roomRepository.AddRoom("", b);
            }

            if (categoryRepository.Categotyes().Count() == 0)
            {
                categoryRepository.AddCategory("");
            }

            if (tableRepository.Tables().Count() == 0)
            {
                tableRepository.AddTable(1, "", r);
            }

            if (clientRepository.Clients().Count() == 0)
            {
                clientRepository.AddClient("Клиент", "", "", "", "", "", "", "", "", "", "", "");
            }
        }
예제 #2
0
        public ActionResult Create(BranchBE branch, FormCollection collection)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(View(branch));
                }

                branch.BankId = Convert.ToInt32(collection["Bank"].ToString());
                branchRep.AddBranch(branch);
                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
예제 #3
0
 public ActionResult EditBranch(BranchModel branch, FormCollection form)
 {
     branch.State = form["States"].ToString();
     if (ModelState.IsValid)
     {
         if (branch.BranchID == 0)
         {
             repository.AddBranch(branch);
             TempData["alertMessage"] = String.Format("Branch: {0} added suceessfully", branch.Name);
         }
         else
         {
             repository.UpdateBranch(branch);
             TempData["alertMessage"] = String.Format("Branch: {0} updated suceessfully", branch.Name);
         }
         return(RedirectToAction("List"));
     }
     TempData["errorMessage"] = "Some Error Occured ! Please try again after sometime. If the error persists, contact Adminitrator.";
     return(RedirectToAction("Edit", branch));
 }