Esempio n. 1
0
        internal static Party EditParty(PartyModel partyModel, Dictionary <string, string> partyCustomAttributeValues)
        {
            PartyTypeManager partyTypeManager = new PartyTypeManager();
            PartyManager     partyManager     = new PartyManager();
            var party = new Party();

            try
            {
                var newAddPartyCustomAttrValues = new Dictionary <PartyCustomAttribute, string>();
                party = partyManager.Find(partyModel.Id);
                //Update some fields
                party.Description = partyModel.Description;
                party.StartDate   = partyModel.StartDate.HasValue ? partyModel.StartDate.Value : DateTime.MinValue;
                party.EndDate     = partyModel.EndDate.HasValue ? partyModel.EndDate.Value : DateTime.MaxValue;
                party             = partyManager.Update(party);
                foreach (var partyCustomAttributeValueString in partyCustomAttributeValues)
                {
                    PartyCustomAttribute partyCustomAttribute = partyTypeManager.PartyCustomAttributeRepository.Get(int.Parse(partyCustomAttributeValueString.Key));
                    string value = string.IsNullOrEmpty(partyCustomAttributeValueString.Value) ? "" : partyCustomAttributeValueString.Value;
                    newAddPartyCustomAttrValues.Add(partyCustomAttribute, value);
                }
                partyManager.AddPartyCustomAttributeValues(party, partyCustomAttributeValues.ToDictionary(cc => long.Parse(cc.Key), cc => cc.Value));
            }
            finally
            {
                partyTypeManager?.Dispose();
                partyManager?.Dispose();
            }
            return(party);
        }
Esempio n. 2
0
        public async Task <PartyResponse> AddPartyRL(PartyRequest partyRequest, string adminId)
        {
            try
            {
                var newParty = new PartyModel()
                {
                    PartyName    = partyRequest.PartyName,
                    RegisteredBy = partyRequest.RegisterBy,
                    CreatedDate  = DateTime.Now,
                    MofifiedDate = DateTime.Now
                };
                authenticationContext.Parties.Add(newParty);
                await this.authenticationContext.SaveChangesAsync();

                if (newParty != null)
                {
                    var partyResponse = new PartyResponse()
                    {
                        Id           = newParty.Id,
                        PartyName    = newParty.PartyName,
                        RegisteredBy = newParty.RegisteredBy
                    };
                    return(partyResponse);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception exception)
            {
                throw new Exception(exception.Message);
            }
        }
Esempio n. 3
0
        public ActionResult PartyEdit(int id, PartyModel model)
        {
            var service = new PartyService();

            service.UpdateParty(model);
            return(RedirectToAction("GetAllParties", "Admin", null));
        }
Esempio n. 4
0
        public ActionResult PartyDelete(int id, PartyModel collection)
        {
            var service = new PartyService();

            service.DeleteParty(id);
            return(RedirectToAction("GetAllParties", "Admin", null));
        }
Esempio n. 5
0
        public ActionResult List()
        {
            var model = new List <PartyModel>();

            try
            {
                var parties     = m_internetDc.Parties.ToList();
                var partyImages = new List <string>();
                int i           = 0;
                foreach (var item in parties)
                {
                    var partyModel = new PartyModel();
                    partyImages.Add(string.Format("data:image/jpg;base64,{0}", Convert.ToBase64String(item.Image.ToArray())));
                    i++;
                    if (!string.IsNullOrEmpty(item.Manager))
                    {
                        var citizen = m_internetDc.Citizens.First(x => x.IdentityNo == item.Manager);
                        partyModel.Manager = citizen;
                    }
                    partyModel.Party = item;
                    model.Add(partyModel);
                }
                ViewData["PartyImages"] = partyImages;
            }
            catch (Exception)
            { }

            return(View(model));
        }
Esempio n. 6
0
        public ActionResult PartyCreate(PartyModel model)
        {
            var service = new PartyService();
            var result  = service.CreateParty(model);

            return(RedirectToAction("GetAllParties", "Admin", null));
        }
Esempio n. 7
0
        public ActionResult SavePartyDetails(PartyModel objPartyModel)
        {
            ResponseDetail objResponse = new ResponseDetail();

            objPartyModel.LoginUser = Session["LoginUser"] as User;
            objResponse             = objRegistrationManager.SavePartyDetails(objPartyModel);
            return(Json(objResponse, JsonRequestBehavior.AllowGet));
        }
Esempio n. 8
0
        public PartyModel getPartyById(int id)
        {
            Mapper.CreateMap <PartyMaster, PartyModel>();
            PartyMaster objComp  = Dbcontext.PartyMasters.SingleOrDefault(m => m.PID == id);
            PartyModel  objCItem = Mapper.Map <PartyModel>(objComp);

            return(objCItem);
        }
Esempio n. 9
0
        public ActionResult Edit(PartyModel model)
        {
            PartyServices objPservice = new PartyServices();

            model.CompID = Convert.ToInt32(Session["CompID"].ToString());
            objPservice.Update(model);
            return(RedirectToAction("Create", new { @menuId = model.Viewbagidformenu }));
        }
Esempio n. 10
0
        public async Task JoinParty(string partyName, string playerObj)
        {
            var player = CompressionHelper.Decompress <PlayerModel>(playerObj);

            var ladder = await _ladderService.GetLadderForPlayer(player.Character.League, player.Character.Name);

            if (ladder == null)
            {
                ladder = await _ladderService.GetLadderForLeague(player.Character.League);
            }
            player.LadderInfo = ladder;

            // set initial id of player
            player.ConnectionID = Context.ConnectionId;

            //update ConnectionId:Partyname index
            await AddToIndex(partyName);

            // look for party
            var party = await _cache.GetAsync <PartyModel>($"party:{partyName}");

            if (party == null)
            {
                party = new PartyModel()
                {
                    Name = partyName, Players = new List <PlayerModel> {
                        player
                    }
                };
                await _cache.SetAsync <PartyModel>($"party:{partyName}", party);

                await Clients.Caller.SendAsync("EnteredParty", CompressionHelper.Compress(party), CompressionHelper.Compress(player));
            }
            else
            {
                var oldPlayer = party.Players.FirstOrDefault(x => x.Character.Name == player.Character.Name || x.ConnectionID == player.ConnectionID);

                if (oldPlayer == null)
                {
                    party.Players.Insert(0, player);
                }
                else
                {
                    var index = party.Players.IndexOf(oldPlayer);
                    party.Players[index] = player;
                }

                await _cache.SetAsync <PartyModel>($"party:{partyName}", party);

                await Clients.Caller.SendAsync("EnteredParty", CompressionHelper.Compress(party), CompressionHelper.Compress(player));
            }

            await Groups.AddToGroupAsync(Context.ConnectionId, partyName);

            await Clients.OthersInGroup(partyName).SendAsync("PlayerJoined", CompressionHelper.Compress(player));

            await Clients.Group(partyName).SendAsync("PlayerUpdated", CompressionHelper.Compress(player));
        }
Esempio n. 11
0
        public int Update(PartyModel model)
        {
            Mapper.CreateMap <PartyModel, PartyMaster>();
            PartyMaster objVehicle = DbContext.PartyMasters.SingleOrDefault(m => m.PID == model.PID);

            objVehicle = Mapper.Map(model, objVehicle);
            DbContext.SaveChanges();
            return(DbContext.SaveChanges());
        }
Esempio n. 12
0
        public ActionResult Edit(bool relationTabAsDefault = false)
        {
            PartyManager     partyManager     = null;
            PartyTypeManager partyTypeManager = null;
            UserManager      userManager      = null;

            try
            {
                partyManager     = new PartyManager();
                partyTypeManager = new PartyTypeManager();
                userManager      = new UserManager();
                var user = userManager.FindByNameAsync(HttpContext.User?.Identity?.Name).Result;
                if (user == null)
                {
                    return(RedirectToAction("Index", "Home", new { area = "" }));
                }
                ViewBag.Title = PresentationModel.GetGenericViewTitle("Edit Party");
                var model = new PartyModel();
                model.PartyTypeList = partyTypeManager.PartyTypeRepository.Get().ToList();
                Party party = partyManager.GetPartyByUser(user.Id);
                if (party == null)
                {
                    return(RedirectToAction("UserRegistration", "PartyService", new { area = "bam" }));
                }
                model.Description = party.Description;
                model.Id          = party.Id;
                model.PartyType   = party.PartyType;
                //Set dates to null to not showing the minimum and maximum dates in UI
                if (party.StartDate == DateTime.MinValue)
                {
                    model.StartDate = null;
                }
                else
                {
                    model.StartDate = party.StartDate;
                }
                if (party.EndDate.Date == DateTime.MaxValue.Date)
                {
                    model.EndDate = null;
                }
                else
                {
                    model.EndDate = party.EndDate;
                }
                model.Name = party.Name;
                ViewBag.RelationTabAsDefault = false;
                ViewBag.Title = "Edit party";

                return(View(model));
            }
            finally
            {
                partyManager?.Dispose();
                partyTypeManager?.Dispose();
                userManager?.Dispose();
            }
        }
Esempio n. 13
0
        public bool SaveData(PartyModel party)
        {
            bool status = true;

            PartyRepository repo = new PartyRepository();

            status = repo.SaveEdit(ParserAddParty(party));
            return(status);
        }
Esempio n. 14
0
        public async Task UpdatePartyAsync(PartyModel model)
        {
            using (var context = new StudentElectionContext())
            {
                var party = context.Parties.SingleOrDefault(p => p.Id == model.Id);
                _mapper.Map(model, party);

                await context.SaveChangesAsync();
            }
        }
Esempio n. 15
0
        public ActionResult getParty(int SID)
        {
            List <PartyModel>  lstVhcl  = new List <PartyModel>();
            PartyModel         objModel = new PartyModel();
            ConsignmentService objEmp   = new ConsignmentService();

            objModel = objEmp.getPartyById(SID);
            return(PartialView("_Contact", objModel));
            //return Json(objModel, JsonRequestBehavior.AllowGet);
        }
Esempio n. 16
0
        public async Task DeletePartyAsync(PartyModel model)
        {
            using (var context = new StudentElectionContext())
            {
                var party = context.Parties.SingleOrDefault(p => p.Id == model.Id);
                context.Parties.Remove(party);

                await context.SaveChangesAsync();
            }
        }
        public JsonResult AddParty([FromBody] PartyModel party)
        {
            var result = _partyservice.AddParty(party);

            if (!result)
            {
                return(new JsonResult("Party could not be added"));
            }

            return(new JsonResult("Party Added"));
        }
Esempio n. 18
0
        private async void tbkParty_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (AreCandidatesFinalized)
            {
                return;
            }

            var tbk = sender as TextBlock;

            var parentWindow = Window.GetWindow(this);
            var window       = parentWindow as MaintenanceWindow;

            G.WaitLang(window);
            Cursor = Cursors.Wait;

            window.Opacity = 0.5;

            var form = new PartyForm();

            _party     = this.DataContext as PartyModel;
            form.Party = _party;

            var helper = new WindowInteropHelper(window);

            SetWindowLong(new HandleRef(form, form.Handle), -8, helper.Handle.ToInt32());

            G.EndWait(window);
            Cursor = Cursors.Arrow;

            form.ShowDialog();

            G.WaitLang(window);

            var party = await form.GetNewDataAsync();

            if (!form.IsDeleted && party != null)
            {
                DataContext = party;
                foreach (CandidateControl control in stkCandidate.Children)
                {
                    var candidate = control.DataContext as CandidateModel;
                    candidate.Party     = party;
                    control.DataContext = candidate;
                }
            }
            else
            {
                await window.LoadCandidatesAsync();
            }

            window.Opacity = 1;

            G.EndWait(window);
        }
Esempio n. 19
0
        public PartyModel GetParty(int id)
        {
            PartyModel      party = new PartyModel();
            PartyRepository repo  = new PartyRepository();

            if (party != null)
            {
                party = ParserParty(repo.GetParty(id));
            }
            return(party);
        }
        public async Task DeletePartyAsync(PartyModel model)
        {
            await Task.CompletedTask;

            using (var tableAdapter = new PartyTableAdapter())
            {
                tableAdapter.Delete(
                    model.Id
                    );
            }
        }
Esempio n. 21
0
        /// <summary>
        /// Service Method To Get Parties
        /// </summary>
        /// <param name="party"></param>
        /// <returns></returns>
        public static async Task <List <PartyModel> > GetParty(PartyModel party)
        {
            List <PartyModel> Parties = new List <PartyModel>();

            using (SqlConnection dbConn = new SqlConnection(selectConnection(party.Location)))
            {
                var           isExistingParty = "SELECT * from Party";
                SqlDataReader reader;

                try
                {
                    dbConn.Open();
                    SqlCommand cmd = new SqlCommand(isExistingParty, dbConn);
                    reader = await cmd.ExecuteReaderAsync();

                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            PartyModel partyItem = new PartyModel();
                            partyItem.ID   = reader.GetInt32(0);
                            partyItem.Name = reader.GetString(1);
                            Parties.Add(partyItem);
                        }
                    }
                }
                catch (Exception ex)
                {
                    reader = null;
                    ActionLogService.LogAction(new ActionLogModel()
                    {
                        UserID          = party.UserID,
                        ActionPerformed = "Party Exists Error : " + ex.Message,
                        MethodName      = "PartyExists",
                        IsError         = true
                    },
                                               party.Location);
                }
                finally
                {
                    dbConn.Close();
                    ActionLogService.LogAction(new ActionLogModel()
                    {
                        UserID          = party.UserID,
                        ActionPerformed = "Check If Party Exists",
                        MethodName      = "PartyExists",
                        IsError         = false
                    },
                                               party.Location);
                }

                return(Parties);
            }
        }
Esempio n. 22
0
        public async Task <IActionResult> Add(ConcertViewModel model)
        {
            if (ModelState.IsValid)
            {
                ConcertModel concert = await _context.Concerts.FirstOrDefaultAsync(u => u.Name == model.Name);

                if (concert == null)
                {
                    ConcertModel c = new ConcertModel(model);

                    if (model.Type == nameof(ClassicalConcertModel))
                    {
                        ClassicalConcertModel classicConcert = new ClassicalConcertModel(c);
                        classicConcert.VocalType            = model.VocalType;
                        classicConcert.ClassicalConcertName = model.ClassicalConcertName;
                        classicConcert.Composer             = model.Composer;

                        _context.ClassicalConcerts.Add(classicConcert);
                    }
                    else if (model.Type == nameof(OpenAirModel))
                    {
                        OpenAirModel openAir = new OpenAirModel(c);

                        openAir.DriveWay  = model.DriveWay;
                        openAir.Headliner = model.Headliner;

                        _context.OpenAirs.Add(openAir);
                    }
                    else if (model.Type == nameof(PartyModel))
                    {
                        PartyModel party = new PartyModel(c);
                        party.AgeQualification = model.AgeQualification.Value;
                        _context.Parties.Add(party);
                    }
                    else
                    {
                        ModelState.AddModelError("", "Некорректные данные");
                    }

                    await _context.SaveChangesAsync();

                    return(RedirectToAction("Index", "Concerts"));
                }
                else
                {
                    ModelState.AddModelError("", "Некорректные данные");
                }
            }
            else
            {
                ModelState.AddModelError("", "Некорректные данные");
            }
            return(View(model));
        }
        public async Task <int> DeletePartyAsync(PartyModel model)
        {
            var party = new Party {
                PartyId = model.PartyId
            };

            using (var dataService = DataServiceFactory.CreateDataService())
            {
                return(await dataService.DeletePartyAsync(party));
            }
        }
Esempio n. 24
0
        public void Execute()
        {
            PartyModel model = AmbitionApp.GetModel <PartyModel>();

            CommodityVO[] commodity =
            {
                new CommodityVO(CommodityType.Reputation, null,                -model.FleePartyPenalty),
                new CommodityVO(CommodityType.Reputation, model.Party.Faction, -model.FleeFactionPenalty)
            };
            AmbitionApp.SendMessage(commodity);
        }
Esempio n. 25
0
 private void validateAttribute(PartyModel partyModel)
 {
     if (partyModel.StartDate > partyModel.EndDate)
     {
         partyModel.Errors.Add(new IO.Transform.Validation.Exceptions.Error(IO.Transform.Validation.Exceptions.ErrorType.Other, "Start date is greater than end date!"));
     }
     if (partyModel.PartyType.Id == 0)
     {
         partyModel.Errors.Add(new IO.Transform.Validation.Exceptions.Error(IO.Transform.Validation.Exceptions.ErrorType.Other, "Please select party type!"));
     }
 }
Esempio n. 26
0
        public PartyItemControl()
        {
            InitializeComponent();

            tbkParty.DataContextChanged += (s, ev) =>
            {
                _party = this.DataContext as PartyModel;

                tbkParty.Width = double.NaN;
            };
        }
Esempio n. 27
0
 public IResult Execute(PartyModel repo, IRegisteredCommand comm)
 {
     if (comm.BaseCommandText == CommandText)
     {
         return(new Result());
     }
     else
     {
         return(_NextCommand.Execute(repo, comm));
     }
 }
Esempio n. 28
0
    public string AddNewParty(GameObject party, bool automatic_start = false)
    {
        PartyController pc = party.GetComponent <PartyController> ();
        PartyModel      pm = party.GetComponent <PartyModel> ();

        DebugLogger.DebugSystemMessage("Inserting " + pm._AdventureTitle + " Party to Dungeon");

        pc.RegisterToEvent(HandlePacketTimerUp);
        string newPacketKey = AddPartyToDungeon(party);

        return(newPacketKey);
    }
Esempio n. 29
0
 public ActionResult UpdateParty(PartyModel partyModel)
 {
     try
     {
         _partyService.UpdateParty(partyModel);
         return(Ok(new { Success = true, data = "Success" }));
     }
     catch (Exception ex)
     {
         return(StatusCode((int)HttpStatusCode.InternalServerError, new { Success = false, data = "Internal Server Error", Message = ex.Message }));
     }
 }
 public IResult Execute(PartyModel repo, IRegisteredCommand comm)
 {
     if (comm.BaseCommandText == CommandText)
     {
         string printString = repo.PrettyPrint();
         return(new Result(printString));
     }
     else
     {
         return(_NextCommand.Execute(repo, comm));
     }
 }