public async Task <ActionResult> DeleteConfirmed(int id)
        {
            Repairman repairman = await db.Repairmen.FindAsync(id);

            db.Repairmen.Remove(repairman);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
        private IClassEquipment buyClassEquipment(BattlefieldRobot r, int classEquipmentId)
        {
            IClassEquipment classEquipment = null;

            {
                Tank tank = r as Tank;
                if (tank != null)
                {
                    classEquipment = tank.Gun;
                    if (gunsById.TryGetValue(classEquipmentId, out Gun wantedBuy) && !wantedBuy.Equals(classEquipment))
                    {
                        if (r.Gold >= wantedBuy.COST)
                        {
                            r.Gold  -= wantedBuy.COST;
                            tank.Gun = wantedBuy;
                        }
                    }
                }
            }

            {
                MineLayer mineLayer = r as MineLayer;
                if (mineLayer != null)
                {
                    classEquipment = mineLayer.MineGun;
                    if (mineGunsById.TryGetValue(classEquipmentId, out MineGun wantedBuy) && !wantedBuy.Equals(classEquipment))
                    {
                        if (r.Gold >= wantedBuy.COST)
                        {
                            r.Gold           -= wantedBuy.COST;
                            mineLayer.MineGun = wantedBuy;
                        }
                    }
                }
            }

            {
                Repairman repairman = r as Repairman;
                if (repairman != null)
                {
                    classEquipment = repairman.RepairTool;
                    if (repairToolsById.TryGetValue(classEquipmentId, out RepairTool wantedBuy) && !wantedBuy.Equals(classEquipment))
                    {
                        if (r.Gold >= wantedBuy.COST)
                        {
                            r.Gold -= wantedBuy.COST;
                            repairman.RepairTool = wantedBuy;
                        }
                    }
                }
            }
            return(classEquipment);
        }
        public async Task <ActionResult> Edit([Bind(Include = "ID,Wage,FirstName,LastName")] Repairman repairman)
        {
            if (ModelState.IsValid)
            {
                db.Entry(repairman).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(repairman));
        }
        public async Task <ActionResult> Create([Bind(Include = "ID,Wage,FirstName,LastName")] Repairman repairman)
        {
            if (ModelState.IsValid)
            {
                db.Repairmen.Add(repairman);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(repairman));
        }
Exemple #5
0
        public static bool PushForRepairman(IScoringGenerator stats, StoryProgressionObject manager, Household house)
        {
            List <SimDescription> choices = manager.Situations.GetFree(stats, new SimScoringList(stats, "Handiness", manager.Sims.TeensAndAdults, false).GetBestByMinScore(1), true);

            Dictionary <Household, List <GameObject> > repairs = new Dictionary <Household, List <GameObject> >();

            foreach (Lot lot in ManagerLot.GetOwnedLots(house))
            {
                GetRepairs(manager, lot.GetObjects <GameObject>(), repairs);
            }

            stats.AddStat("Residents", choices.Count);

            while (choices.Count > 0)
            {
                SimDescription choice = RandomUtil.GetRandomObjectFromList(choices);
                choices.Remove(choice);

                if (choice.CreatedSim == null)
                {
                    continue;
                }

                List <GameObject> repairWork = null;
                if (repairs.TryGetValue(house, out repairWork))
                {
                    if (PushInteractions(manager, choice, repairWork))
                    {
                        stats.IncStat("Resident Repairman");
                        return(true);
                    }
                    else
                    {
                        stats.IncStat("Push Fail");
                    }
                }
                else
                {
                    stats.IncStat("No Repairs Fonud");
                }
            }

            stats.IncStat("Service Repairman");

            Repairman instance = Repairman.Instance;

            if (instance != null)
            {
                instance.MakeServiceRequest(house.LotHome, true, ObjectGuid.InvalidObjectGuid);
            }
            return(true);
        }
 public bool Insert(Repairman repairman)
 {
     try
     {
         _context.Entry(repairman).State = EntityState.Added;
         _context.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
Exemple #7
0
        public ActionResult changeRate(string star, string comment, int r, int c, string page)
        {
            IEnumerable <Review> reviews = _ReviewService.GetByBothId(r, c);

            if (Equals(star, ""))
            {
                star = "0";
            }
            if (reviews.Count() > 0)
            {
                foreach (var item in reviews)
                {
                    item.Rating  = Convert.ToDouble(star);
                    item.Comment = comment;
                    _ReviewService.Update(item);
                }
            }

            else
            {
                Review r1 = new Review();

                r1.CustomerID  = c;
                r1.RepairmanID = r;
                r1.Rating      = Convert.ToDouble(star);
                r1.Comment     = comment;
                _ReviewService.Insert(r1);
            }
            Repairman rr = _RepairmanService.GetById(r);

            IEnumerable <Review> reviews1 = _ReviewService.GetByRepairmanId(r);
            double rat;

            if (reviews1.Count() != 0)
            {
                rat       = (((reviews1.Count() - 1) * rr.Rating) + Convert.ToDouble(star)) / reviews1.Count();
                rr.Rating = rat;
            }
            _RepairmanService.Update(rr);

            if (Equals(page, "myServices"))
            {
                return(RedirectToAction(page, "Customer"));
            }

            else
            {
                return(RedirectToAction(page, "Customer", new { id = r }));
            }
        }
 public bool Update(Repairman repairman)
 {
     if (_context.Set <Repairman>().Any(e => e.RepairmanID == repairman.RepairmanID))
     {
         _context.Set <Repairman>().Attach(repairman);
         _context.Entry(repairman).State = EntityState.Modified;
         _context.SaveChanges();
         return(true);
     }
     else
     {
         return(false);
     }
 }
        // GET: Repairmen/Delete/5
        public async Task <ActionResult> Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Repairman repairman = await db.Repairmen.FindAsync(id);

            if (repairman == null)
            {
                return(HttpNotFound());
            }

            return(View(repairman));
        }
Exemple #10
0
        public ActionResult undoRepairman(int id, int rid)
        {
            Request r = _RequestService.GetById(id);

            r.RepairmanID = 0;
            r.Status      = "Pending";
            _RequestService.Update(r);

            Repairman r1 = _RepairmanService.GetById(rid);

            r1.Status = "Idle";
            _RepairmanService.Update(r1);


            return(RedirectToAction("viewpendingservice", new { id = r.RequestID }));
        }
        protected void initRobot(BattlefieldRobot robot)
        {
            robot.Motor     = Motors[0];
            robot.Armor     = Armors[0];
            robot.HitPoints = robot.Armor.MAX_HP;

            switch (robot.ROBOT_TYPE)
            {
            case RobotType.MINE_LAYER:
                MineLayer mineLayer = robot as MineLayer;
                if (mineLayer != null)
                {
                    mineLayer.MineGun  = MineGuns[0];
                    mineLayer.MinesNow = 0;
                    mineLayer.MINES_BY_ID.Clear();
                }
                break;

            case RobotType.TANK:
                Tank tank = robot as Tank;
                if (tank != null)
                {
                    tank.Gun        = Guns[0];
                    tank.GunsToLoad = 0;
                }
                break;

            case RobotType.REPAIRMAN:
                Repairman repairman = robot as Repairman;
                if (repairman != null)
                {
                    repairman.RepairTool     = RepairTools[0];
                    repairman.RepairToolUsed = 0;
                }
                break;

            default:
                throw new NotSupportedException("Unsupported type of robot.");
            }

            Point position = obstacleManager.StartRobotPosition(ARENA_MAX_SIZE, ARENA_MAX_SIZE);

            robot.X = position.X;
            robot.Y = position.Y;
        }
Exemple #12
0
        public ActionResult completeRequest(int id)
        {
            if ((Session["userId"] == null) || (Convert.ToInt32(Session["type"]) != 2))
            {
                return(RedirectToAction("login", "Common"));
            }

            Request request = _RequestService.GetById(id);

            request.Status = "Completed";
            _RequestService.Update(request);

            Repairman repairman = _RepairmanService.GetById(request.RepairmanID);

            repairman.Status = "Idle";
            _RepairmanService.Update(repairman);
            return(RedirectToAction("dashboard", "Repairman"));
        }
        private ACommand repairProcess(RepairCommand command, Battlefield.RobotAndBattlefield robotAndBattlefield)
        {
            Battlefield battlefield = robotAndBattlefield.BATTLEFIELD;
            Repairman   repairman   = robotAndBattlefield.ROBOT as Repairman;

            if (repairman == null)
            {
                return(new ErrorCommand(robotAndBattlefield.ROBOT.ROBOT_TYPE + " cannot use repair command."));
            }

            if (repairman.RepairToolUsed < repairman.RepairTool.MAX_USAGES && repairman.HitPoints > 0)
            {
                foreach (BattlefieldRobot robot in battlefield.robots)
                {
                    if (robot.HitPoints > 0)
                    {
                        double distance = EuclideanSpaceUtils.Distance(robot.Position,
                                                                       repairman.Position);
                        if (distance < command.MAX_DISTANCE)
                        {
                            Zone zone = Zone.GetZoneByDistance(repairman.RepairTool.ZONES, distance);
                            robot.HitPoints += zone.EFFECT;
                            robot.HitPoints  = Math.Min(robot.HitPoints, robot.Armor.MAX_HP);
                            if (repairman != robot)
                            {
                                repairman.Score += zone.EFFECT;
                            }
                        }

                        battlefield.battlefieldTurn.AddRepair(new ViewerLibrary.Repair(robot.X, robot.Y));
                    }
                }
                repairman.RepairToolUsed++;
                return(new RepairAnswerCommand(true));
            }
            else
            {
                return(new RepairAnswerCommand(false));
            }
        }
Exemple #14
0
 void Awake()
 {
     instance = this;
     _ik      = GetComponent <IKControl>();
     _anim    = GetComponent <Animator>();
 }
        private ACommand initProcess(InitCommand command, Battlefield.NetworkStreamAndBattlefield networkStreamAndBattlefield)
        {
            Battlefield battlefield = networkStreamAndBattlefield.BATTLEFIELD;

            IClassEquipment classEquipment = null;

            // get teamId for this robot
            if (!battlefield.robotTeamIdByTeamName.TryGetValue(command.TEAM_NAME, out int teamId))
            {
                lock (battlefield.robotsByTeamId) {
                    lock (battlefield.robotTeamIdByTeamName) {
                        if (battlefield.robotTeamIdByTeamName.Count < battlefield.TEAMS)
                        {
                            teamId = battlefield.idForTeam++;
                            battlefield.robotsByTeamId[teamId] = new List <BattlefieldRobot>();
                            battlefield.robotTeamIdByTeamName.Add(command.TEAM_NAME, teamId);
                        }
                        else
                        {
                            return(new ErrorCommand("Too many teams."));
                        }
                    }
                }
            }
            else
            {
                lock (battlefield.robotsByTeamId) {
                    if (battlefield.robotsByTeamId[teamId].Count >= battlefield.ROBOTS_IN_TEAM)
                    {
                        return(new ErrorCommand("Too many robots in one team."));
                    }
                }
            }

            BattlefieldRobot robot;

            // create robot
            switch (command.ROBOT_TYPE)
            {
            case RobotType.MINE_LAYER:
                robot = new MineLayer(teamId, idForRobot++, networkStreamAndBattlefield.NETWORK_STREAM);
                initRobot(robot);
                classEquipment = ((MineLayer)robot).MineGun;
                break;

            case RobotType.TANK:
                robot = new Tank(teamId, idForRobot++, networkStreamAndBattlefield.NETWORK_STREAM);
                initRobot(robot);
                classEquipment = ((Tank)robot).Gun;
                break;

            case RobotType.REPAIRMAN:
                robot = new Repairman(teamId, idForRobot++, networkStreamAndBattlefield.NETWORK_STREAM);
                initRobot(robot);
                classEquipment = ((Repairman)robot).RepairTool;
                break;

            default:
                return(new ErrorCommand("Unsupported RobotType (" + command.ROBOT_TYPE + ") support only" + RobotType.MINE_LAYER + ", " + RobotType.TANK + ", " + RobotType.REPAIRMAN));
            }


            lock (battlefield.robots) {
                battlefield.robots.Add(robot);
            }
            lock (battlefield.robotsById) {
                battlefield.robotsById[robot.ID] = robot;
            }
            lock (battlefield.robotsByTeamId) {
                battlefield.robotsByTeamId[teamId].Add(robot);
            }

            lock (battlefield.robotsByStream) {
                battlefield.robotsByStream.Add(networkStreamAndBattlefield.NETWORK_STREAM, robot);
            }
            robot.NAME = command.NAME;

            lock (battlefield.battlefieldTurn) {
                battlefield.battlefieldTurn.AddRobot(new Robot(robot.ID, robot.TEAM_ID, robot.Score, robot.Gold, robot.HitPoints, robot.X, robot.Y,
                                                               robot.AngleDrive, robot.NAME));
                battlefield.turnDataModel?.Add(battlefieldTurn.ConvertToTurn(), false);
                battlefield.viewer?.StepNext();
            }

            return(battlefield.addToInitAnswerCommand(new InitAnswerCommand(battlefield.MAX_TURN, battlefield.lap, battlefield.MAX_LAP,
                                                                            robot.ID, robot.TEAM_ID, classEquipment.ID, robot.Armor.ID, robot.Motor.ID)));
        }
Exemple #16
0
        public void InsertInTable()
        {
            RepairAnywhereDbContext radb = new RepairAnywhereDbContext();

            //Insert Admin

            AdminService AS = new AdminService(radb);

            Admin a1 = new Admin();

            a1.Name        = "admin";
            a1.PhoneNumber = 01111111111;
            a1.Email       = "*****@*****.**";
            a1.Password    = "******";

            CustomerService CS = new CustomerService(radb);

            Customer c1 = new Customer();

            c1.Email       = "*****@*****.**";
            c1.Password    = "******";
            c1.Name        = "mac";
            c1.PhoneNumber = "2342";
            c1.Address     = "Mirpur1";
            c1.Status      = "Idle";
            c1.MemberSince = DateTime.Now;
            c1.LastLogin   = DateTime.Now;


            RepairmanService RS = new RepairmanService(radb);

            Repairman r1 = new Repairman();

            r1.Name        = "mac2";
            r1.Email       = "*****@*****.**";
            r1.PhoneNumber = "7007";
            r1.Password    = "******";
            r1.Address     = "Mirpur2";
            r1.Status      = "Idle";
            r1.Rating      = 4.0;
            r1.MemberSince = DateTime.Now;
            r1.LastLogin   = DateTime.Now;



            LoginService LS = new LoginService(radb);

            Login l1 = new Login();

            l1.Username = "******";
            l1.Password = "******";
            l1.UserID   = 1;
            l1.UserType = "Admin";

            Login l2 = new Login();

            l2.Username = "******";
            l2.Password = "******";
            l2.UserID   = 1;
            l2.UserType = "Customer";

            Login l3 = new Login();

            l3.Username = "******";
            l3.Password = "******";
            l3.UserID   = 1;
            l3.UserType = "Repairman";



            Console.WriteLine("\n inseted " + AS.Insert(a1) + RS.Insert(r1) + CS.Insert(c1) + LS.Insert(l1) + LS.Insert(l2) + LS.Insert(l3));
        }
        public ActionResult register(string Name, string Email, string PhoneNumber, string address, string Password1, string Password)
        {
            IEnumerable <Login> logins = _LoginService.GetAll();
            RegisterViewModel   RVM    = new RegisterViewModel();

            RVM.flag = 0;
            foreach (var item in logins)
            {
                if (Equals(item.Username, Name))
                {
                    RVM.flag = 1;
                    return(View(RVM));
                }
            }

            if (Equals(Password, Password1))
            {
                if (Convert.ToInt32(Session["log"]) == 1)
                {
                    Customer c = new Customer();
                    c.Name        = Name;
                    c.Email       = Email;
                    c.Password    = Password1;
                    c.MemberSince = DateTime.Now;
                    c.PhoneNumber = PhoneNumber;
                    c.Address     = address;
                    c.LastLogin   = DateTime.Now;

                    _CustomerService.Insert(c);

                    IEnumerable <Customer> CA = _CustomerService.GetAll();

                    foreach (var item in CA)
                    {
                        c = item;
                    }

                    Login l = new Login();
                    l.Username = Name;
                    l.Password = Password1;
                    l.UserType = "Customer";
                    l.UserID   = c.CustomerID;

                    _LoginService.Insert(l);
                }

                else
                {
                    Repairman r = new Repairman();
                    r.Name        = Name;
                    r.Email       = Email;
                    r.Password    = Password1;
                    r.MemberSince = DateTime.Now;
                    r.PhoneNumber = PhoneNumber;
                    r.Address     = address;
                    r.LastLogin   = DateTime.Now;
                    r.Status      = "Idle";
                    r.Rating      = 1;
                    _RepairmanService.Insert(r);

                    IEnumerable <Repairman> RA = _RepairmanService.GetAll();

                    foreach (var item in RA)
                    {
                        r = item;
                    }

                    Login l = new Login();
                    l.Username = Name;
                    l.Password = Password1;
                    l.UserType = "Repairman";
                    l.UserID   = r.RepairmanID;

                    _LoginService.Insert(l);
                }
                return(RedirectToAction("index", "Common"));
            }
            else
            {
                RVM.flag = 2;
                return(View(RVM));
            }
        }