Exemplo n.º 1
0
        public ActionResult BranchList()
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    string errorMessage = (from state in ModelState.Values
                                           from error in state.Errors
                                           select error.ErrorMessage).FirstOrDefault().ToString();
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest, errorMessage));
                }

                using (BranchLogic logic = new BranchLogic())
                {
                    var q = logic.GetAllBranches().Select(m => new
                    {
                        BranchID      = m.BranchID,
                        DetailsString = m.BranchName + " " + m.Address
                    }).ToList();

                    return(Json(q, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest, "We have problem on the server, Please try again later!"));
            }
        }
Exemplo n.º 2
0
        public void Endif()
        {
            var f = FuncBuilder.Instance;

            f.FinishInflightUtterance(cookie);
            using (f.OpenScope("if")) {
                var elseLabel  = f.DeclareLabel("else");
                var endifLabel = f.DeclareLabel("endif");
                condition.BranchIf(false, elseLabel);
                using (f.OpenScope("truePart")) {
                    thenAction();
                    if (elseAction != null)
                    {
                        BranchLogic.UnconditionalBranchTo(endifLabel);
                    }
                }
                using (f.OpenScope("falsePart")) {
                    elseLabel.Mark();
                    if (elseAction != null)
                    {
                        elseAction();
                    }
                }
                endifLabel.Mark();
            }
        }
Exemplo n.º 3
0
        public ActionResult Create(Branch branch)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    if (!(String.IsNullOrEmpty(branch.Name) || String.IsNullOrEmpty(branch.Address)))
                    {
                        //validate branch name and sort code
                        BranchLogic branchLogic = new BranchLogic();
                        if (branchLogic.IsBranchNameExists(branch.Name))
                        {
                            ViewBag.Msg = "Branch name must be unique";
                            return(View());
                        }

                        branch.Status   = BranchStatus.Closed;
                        branch.SortCode = branchLogic.GetSortCode();
                        branchRepo.Insert(branch);
                        return(RedirectToAction("Create", new { message = "Successfully added Branch!" }));
                    }
                    ViewBag.Msg = "Please enter branch name and address";
                    return(View());
                }
                catch (Exception ex)
                {
                    //ErrorLogger.Log("Message= " + ex.Message + "\nInner Exception= " + ex.InnerException + "\n");
                    return(PartialView("Error"));
                }
            }
            ViewBag.Msg = "Please enter a valid name and address";
            return(View());
        }
Exemplo n.º 4
0
 public FormEmployee(EmployeeLogic employeeLogic, BranchLogic branchLogic, PostLogic postLogic)
 {
     InitializeComponent();
     this.employeeLogic = employeeLogic;
     _branchLogic       = branchLogic;
     _postLogic         = postLogic;
 }
Exemplo n.º 5
0
        public void Do(Action body)
        {
            var f = FuncBuilder.Instance;

            f.FinishInflightUtterance(cookie);
            using (f.OpenScope("while")) {
                var bodyLabel      = f.DeclareLabel("body");
                var conditionLabel = f.DeclareLabel("condition");
                BranchLogic.UnconditionalBranchTo(conditionLabel);
                bodyLabel.Mark();
                body();
                conditionLabel.Mark();
                condition.BranchIf(true, bodyLabel);
            }
        }
Exemplo n.º 6
0
 //Edit Branch page - show only
 public ActionResult Edit(int?BranchID)
 {
     try
     {
         using (BranchLogic logic = new BranchLogic())
         {
             return(View(logic.GetOneBranchDetails(BranchID)));
         }
     }
     catch (Exception)
     {
         ViewBag.Error         = "We have problem on the server, Please try again later!";
         ViewBag.CriticalError = true;
         return(View(new Branch()));
     }
 }
Exemplo n.º 7
0
 //Manage Branches - for the main admin page
 public ActionResult branchesIndex()
 {
     try
     {
         using (BranchLogic logic = new BranchLogic())
         {
             //return PartialView("_BranchesPartial", logic.GetAllBranches());
             return(View("Branches", logic.GetAllBranches()));
         }
     }
     catch (Exception)
     {
         ViewBag.Error = "We have problem on the server, Please try again later!";
         //return PartialView("_BranchesPartial", new List<Branch>());
         return(View("Branches", new List <Branch>()));
     }
 }
        public static void Return(this FuncBuilder f, IntExpression expr)
        {
            using (f.OpenScope("return")) {
                var emitter       = CodeGenerator.Emitter;
                var resultStorage = f.Declare.Int("result");
                var exprResult    = expr.EvaluateTo(resultStorage);

                var exprRegOrByte = exprResult.ToRegisterOrByte(f.Scratch0);
                if (exprRegOrByte.IsRegister)
                {
                    emitter.EmitRegisterMoveIfDifferent(Register.R0, exprRegOrByte.Register);
                }
                else
                {
                    emitter.Emit(Format3OpCode.MOV, Register.R0, exprRegOrByte.Byte);
                }
                BranchLogic.UnconditionalBranchTo(f.TheExitLabel);
            }
        }
Exemplo n.º 9
0
        public ActionResult Edit(Branch Branch)
        {
            //try
            //{
            if (!ModelState.IsValid)
            {
                return(View());
            }

            BranchLogic logic = new BranchLogic();

            logic.EditBranch(Branch);


            return(RedirectToAction("Index", "MangeHome"));
            //}
            //catch
            //{
            //    ViewBag.Error = "We have problem on the server, Please try again later!";
            //    return View(new Branch());
            //}
        }
Exemplo n.º 10
0
        public ActionResult Delete(Branch Branch)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(View());
                }

                BranchLogic logic = new BranchLogic();

                logic.DeleteBranch(Branch);


                return(RedirectToAction("Index", "MangeHome"));
            }
            catch
            {
                ViewBag.Error = "We have problem on the server, Please try again later!";
                return(View(new Branch()));
            }
        }
Exemplo n.º 11
0
 public BranchController(AppContext dbParam, IBranchLogic branchLogicParam)
 {
     db          = new AppContext();
     branchLogic = new BranchLogic(new BranchRepository());
 }
Exemplo n.º 12
0
 public BranchController()
 {
     db          = new AppContext();
     branchLogic = new BranchLogic(new BranchRepository());
     eodLogic    = new EodLogic();
 }