Esempio n. 1
0
    public static string GetCourtList(int StateId, int CourtTypeId)
    {
        string row = "<tr class='gradeA'><td>[OfficeName]</td><td>[City]</td><td>[State]</td><td class='center'>[Zip]</td></tr>";

        List <Court> courts = new List <Court>();
        Court        court  = new Court();
        string       rows   = string.Empty;
        string       temp   = string.Empty;

        //List<CourtLocation> courtts = CourtLocaterHelper.GetCourtList(StateId, CourtTypeId);

        //foreach (CourtLocation courtLocation in courtts)
        //{
        //    temp = row.Replace("[OfficeName]", courtLocation.OfficeName).Replace("[City]", courtLocation.CityId.ToString()).Replace("[State]", courtLocation.StateId.ToString()).Replace("[Zip]", courtLocation.CityId.ToString());
        //    rows = rows + temp;
        //}

        List <State> stateList = new List <State>();

        stateList = StateHelper.GetStateList();

        foreach (State state in stateList)
        {
            temp = row.Replace("[OfficeName]", state.StateId.ToString()).Replace("[City]", state.Name).Replace("[State]", state.AlphaCode).Replace("[Zip]", state.ValidationRuleId.ToString());
            rows = rows + temp;
        }

        return(rows);
    }
        public async Task <IActionResult> Edit(int id, [Bind("Id,CourtType,CourtTownId")] Court court)
        {
            if (id != court.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(court);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CourtExists(court.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CourtTownId"] = new SelectList(_context.CourtTowns, "Id", "Address", court.CourtTownId);
            return(View(court));
        }
Esempio n. 3
0
        public CourtPlayersSelect()
        {
            this.InitializeComponent();

            if (App.SelectedTeam != null)
            {
                if (PlayersViewModel.Instance.PlayersCollection == null)
                {
                    PlayersViewModel.Instance.CollectionLoaded += Setup;
                }
                else if (PlayersViewModel.Instance.PlayersOnCourt.Count == 0)
                {
                    Setup();
                }
                else
                {
                    Court.SetPlayersOnCourt(PlayersViewModel.Instance.PlayersOnCourt);
                    foreach (var p in PlayersViewModel.Instance.PlayersCollection.Except(PlayersViewModel.Instance.PlayersOnCourt))
                    {
                        Players.Add(p);
                    }
                    PlayersListBox.ItemsSource = Players;
                }
            }
            else
            {
                if (PlayersViewModel.Instance.PlayersOnCourt.Count == 0)
                {
                    AddGuestPlayersSource();
                    CreateGuestSets();
                }
            }
        }
Esempio n. 4
0
        private Court ProcessCourtData(string courtData)
        {
            Court court = null;

            if (!string.IsNullOrEmpty(courtData))
            {
                CourtJson courtJson = JsonSerializer.Current.DeserializeObject <CourtJson>(courtData);

                if (null != courtJson && !string.IsNullOrEmpty(courtJson.name))
                {
                    court = this.DB.Court.Where(c => c.CourtId == courtJson.GuidId).FirstOrDefault();

                    if (null == court)
                    {
                        court           = new Court();
                        court.CourtId   = courtJson.GuidId;
                        court.Name      = courtJson.name;
                        court.Latitude  = courtJson.latitude;
                        court.Longitude = courtJson.longitude;

                        this.DB.Court.InsertOnSubmit(court);
                    }
                }
            }

            return(court);
        }
Esempio n. 5
0
        public IQueryable <MultiSelectTransferVM> CourtGroupCodeForSelect_Select(int courtId, int caseGroupId, int caseTypeId)
        {
            int   courtTypeId = -1;
            Court court       = repo.AllReadonly <Court>().Where(x => x.Id == courtId).FirstOrDefault();

            courtTypeId = court?.CourtTypeId ?? -1;
            var typesForCourt = repo.AllReadonly <CourtTypeCaseType>().Where(x => x.CourtTypeId == courtTypeId);

            return(repo.AllReadonly <CaseTypeCode>()
                   .Include(x => x.CaseType)
                   .Include(x => x.CaseCode)
                   .Where(x => ((x.CaseTypeId == caseTypeId) || (caseTypeId <= 0)) &&
                          (x.CaseType.CaseGroupId == caseGroupId) &&
                          typesForCourt.Any(t => t.CaseTypeId == x.CaseTypeId)
                          )
                   .Select(x => x.CaseCode)
                   .GroupBy(x => x.Id)
                   .Select(g => g.First())
                   .Select(x => new MultiSelectTransferVM()
            {
                Id = x.Id,
                Order = x.OrderNumber,
                Text = $"{x.Code} {x.Label}"
            }).AsQueryable());
        }
Esempio n. 6
0
        /// <summary>
        /// This method is called when user edits the user profile containing NTRP/Preference & other tennis user data
        /// </summary>
        /// <param name="ntrp"></param>
        /// <param name="preference"></param>
        /// <returns></returns>
        public ActionResult PostTennisUserDetails(string ntrp, string preference, string courtData, string style, bool emailOffers)
        {
            var fbContext = FacebookWebContext.Current;

            TennisUser tennisUser = this.DB.TennisUser.Where(u => u.FacebookId == fbContext.UserId).FirstOrDefault();
            User       user       = this.DB.User.Where(u => u.FacebookId == fbContext.UserId).FirstOrDefault();

            Court court = ProcessCourtData(courtData);

            user.EmailOffers          = emailOffers;
            tennisUser.Rating         = Convert.ToDouble(ntrp);
            tennisUser.SinglesDoubles = preference;
            tennisUser.Court          = court;
            tennisUser.PlayStyle      = style;

            this.DB.SubmitChanges();

            // Given the user details has changed, update all modules that are potentially impacted besides the UserDetails module itself
            return(Json(
                       new
            {
                UserDetails = RenderPartialViewToString("UserDetails", ModelUtils.GetModel <ModuleModel>(fbContext.UserId, this.DB)),
                QuickMatch = RenderPartialViewToString("QuickMatch", ModelUtils.GetModel <ModuleModel>(fbContext.UserId, this.DB)),
                Players = RenderPartialViewToString("Players", ModelUtils.GetModel <PlayersModel>(FacebookWebContext.Current.UserId, this.DB)),
                PotentialOffers = RenderPartialViewToString("PotentialOffers", ModelUtils.GetModel <PotentialOffersModel>(FacebookWebContext.Current.UserId, this.DB))
            }
                       ));
        }
Esempio n. 7
0
 public IActionResult Add(Court model)
 {
     try
     {
         if (db.Courts.Any(s => s.Id == model.Id))
         {
             var item = db.Courts.FirstOrDefault(s => s.Id == model.Id);
             item.Name        = model.Name;
             item.Adress      = model.Adress;
             item.Description = model.Description;
             item.Image       = model.Image;
             item.Rating      = model.Rating;
             item.RegionId    = model.RegionId;
             db.Update(item);
             db.SaveChanges();
             return(Ok(new { model = db.Courts, apiStatus = "successfully_updated", message = "Successfully updated the court", success = true }));
         }
         db.Add(model);
         db.SaveChanges();
         return(Ok(new { model = db.Courts, apiStatus = "successfully_added", message = "Successfully added the court", success = true }));
     }
     catch (Exception ex)
     {
         return(Ok(new { apiStatus = "internal_error_added", message = ex.Message, success = false }));
     }
 }
Esempio n. 8
0
        public string Create([Bind(Exclude = "Id")] Court Model)
        {
            ApplicationDbContext db = new ApplicationDbContext();
            string msg;

            try
            {
                if (ModelState.IsValid)
                {
                    db.Courts.Add(Model);

                    db.SaveChanges();
                    msg = "Сохранено успешно";
                }
                else
                {
                    msg = "Данные не прошли проверку ввода";
                }
            }
            catch (Exception ex)
            {
                msg = "Произошла ошибка:" + ex.Message;
            }
            return(msg);
        }
Esempio n. 9
0
 public CaseUpdateRecord(Case uc)
 {
     this.updateCase = uc;
     newCase         = new Case();
     court           = new Court();
     InitializeComponent();
 }
Esempio n. 10
0
        public IHttpActionResult PostClub(Club club)
        {
            int noOfCourts;

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            noOfCourts   = club.NoOfCourts;
            club.Status  = 0;
            club.Created = DateTime.Now;
            db.Clubs.Add(club);
            db.SaveChanges();

            for (int i = 0; i <= noOfCourts; i++)
            {
                Court court = new Court();
                court.ClubID   = club.ClubID;
                court.Status   = 0;
                court.CourtNum = i;
                court.club     = club;
                db.Courts.Add(court);
                db.SaveChanges();
            }

            return(CreatedAtRoute("DefaultApi", new { id = club.ClubID }, club));
        }
Esempio n. 11
0
        private void btnCaseSave_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrWhiteSpace(txtCaseName.Text) || string.IsNullOrWhiteSpace(txtCaseId.Text) ||
                string.IsNullOrWhiteSpace(txtCaseDisc.Text) || string.IsNullOrWhiteSpace(txtCasePlaintiff.Text) ||
                string.IsNullOrWhiteSpace(txtCaseDefender.Text) || string.IsNullOrWhiteSpace(txtCaseOppLawyer.Text) ||
                cbCaseCourtCity.SelectedIndex < 0 || cbCaseCourtType.SelectedIndex < 0 || cbCaseType.SelectedIndex < 0 ||
                dpCaseStartDate.SelectedDate == null || cbCaseType.Text == "Select Case Type..")
            {
                MessageBox.Show("All Fields Are Necessary");
                return;
            }
            court = new CourtDA().getCourtsByCourtType_CourtCity(cbCaseCourtType.Text, cbCaseCourtCity.Text);

            if (court != null)
            {
                newCase.CourtId = court.CourtId;
            }
            else
            {
                MessageBox.Show("Court Data not found in your System");
                return;
            }

            if (new CaseDA().saveChangesToDB(updateCase))
            {
                MessageBox.Show("Record Updated..", "Information");
                this.Close();
            }
            else
            {
                MessageBox.Show("Record not updated..", "Information");
            }
        }
Esempio n. 12
0
        public BasketballGui()
        {
            InitializeComponent();
            LogicalCourt = new Court(5, 11);
            _p1          = new Player(LogicalCourt, new Point(LogicalCourt.Height / 2, LogicalCourt.Width - 1))
            {
                Name             = "A1",
                Position         = new Point(LogicalCourt.Height / 2, LogicalCourt.Width / 2 - 1),
                Speed            = 350,
                ShootingAccuracy = 0.8,
            };
            _p2 = new Player(LogicalCourt, new Point(LogicalCourt.Height / 2, 0))
            {
                Name             = "B1",
                Position         = new Point(LogicalCourt.Height / 2, LogicalCourt.Width / 2 + 1),
                Speed            = 1021,
                ShootingAccuracy = 0.5
            };

            // Set ball initial position
            LogicalCourt[LogicalCourt.Height / 2, LogicalCourt.Width / 2] = "B";
            LogicalCourt.BallPos = new Point(LogicalCourt.Height / 2, LogicalCourt.Width / 2);
            // Set players initial positions
            LogicalCourt[LogicalCourt.Height / 2, LogicalCourt.Width / 2 - 1] = "A1";
            LogicalCourt[LogicalCourt.Height / 2, LogicalCourt.Width / 2 + 1] = "B1";
        }
Esempio n. 13
0
        public ActionResult Create([Bind(Include = "courtId,courtDescription,courtImage,doublesCourt,buildingId")] Court court)
        {
            if (Session["currentUser"] == null)
            {
                TempData["message"] = "Please login to continue.";
                return(RedirectToAction("VerifyLogin"));
            }
            if (((TotalSquashNext.Models.User)Session["currentUser"]).accountId != 1)
            {
                TempData["message"] = "You must be an administrator to access this page.";
                return(RedirectToAction("VerifyLogin", "Login"));
            }

            try
            {
                if (ModelState.IsValid)
                {
                    db.Courts.Add(court);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }

            catch
            {
                TempData["Message"] = "ERROR - Please try again";
                return(View());
            }

            ViewBag.buildingId = new SelectList(db.Buildings, "buildingId", "address", court.buildingId);
            return(View(court));
        }
Esempio n. 14
0
        // GET: Courts/Edit/5
        public ActionResult Edit(int?id)
        {
            if (Session["currentUser"] == null)
            {
                TempData["message"] = "Please login to continue.";
                return(RedirectToAction("VerifyLogin"));
            }
            if (((TotalSquashNext.Models.User)Session["currentUser"]).accountId != 1)
            {
                TempData["message"] = "You must be an administrator to access this page.";
                return(RedirectToAction("VerifyLogin", "Login"));
            }
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Court court = db.Courts.Find(id);

            if (court == null)
            {
                return(HttpNotFound());
            }
            ViewBag.buildingId = new SelectList(db.Buildings, "buildingId", "address", court.buildingId);
            return(View(court));
        }
Esempio n. 15
0
        public async Task <ActionResult <Court> > AddCourt(Court court)
        {
            var entityEntry = _context.Courts.Add(court);
            await _context.SaveChangesAsync();

            return(entityEntry.Entity);
        }
        private static CourtSchedule GetScheduleForCourt(Court court, IList <Booking> bookings)
        {
            var schedule = new CourtSchedule();

            schedule.CourtId   = court.Id;
            schedule.CourtName = court.Name;

            for (var hour = court.FirstSlot; hour <= court.LastSlot; hour++)
            {
                var slot = new Slot();
                slot.StartingAt = hour;

                var matchingBooking = (from b in bookings where b.StartingAt == hour select b).FirstOrDefault();
                if (matchingBooking != null)
                {
                    slot.BookingId = matchingBooking.Id;
                    slot.Name      = matchingBooking.Name;
                    slot.Length    = matchingBooking.Length;
                    if (slot.Length > 1)
                    {
                        hour += (slot.Length - 1);
                    }
                }
                schedule.Slots.Add(slot);
            }
            return(schedule);
        }
Esempio n. 17
0
        public IActionResult Edit(string id, [Bind("Id,Summary,Location,Description")] Court court)
        {
            if (id != court.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    Calendar update = _mapper.Map <Calendar>(court);
                    _api.EditCalendar(id, update);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!String.IsNullOrEmpty(court.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(court));
        }
Esempio n. 18
0
    private void Awake()
    {
        CourtType court_type = DataManager.Instance.court_type;
        int       court_num  = (int)court_type;

        if (court_type == CourtType.Random)
        {
            int n = Tools.EnumLength(typeof(CourtType));
            int r = Random.Range(1, n);
            court_num = (court_num + r) % n;
        }

        for (int i = 0; i < transform.childCount; ++i)
        {
            if (i == court_num)
            {
                court = transform.GetChild(i).gameObject.GetComponent <Court>();
                court.gameObject.SetActive(true);
            }
            else
            {
                transform.GetChild(i).gameObject.SetActive(false);
            }
        }
    }
Esempio n. 19
0
        public IActionResult Edit(ICollection <IFormFile> imageFile, Court model, string returnUrl)
        {
            SetViewbag(returnUrl, model.Id);
            ValidateCourt(model);
            if (!ModelState.IsValid)
            {
                return(View(nameof(Edit), model));
            }
            var currentId = model.Id;

            if (imageFile != null && imageFile.Count() > 0)
            {
                var file = imageFile.First();
                using (var ms = new MemoryStream())
                {
                    file.CopyTo(ms);
                    model.CourtLogo = "data:" + (file.ContentType) + ";base64, " + Convert.ToBase64String(ms.ToArray());
                }
            }
            if (commonService.CourtSaveData(model))
            {
                this.SaveLogOperation(currentId == 0, model.Id);
                SetSuccessMessage(MessageConstant.Values.SaveOK);
                return(RedirectToAction(nameof(Edit), new { id = model.Id, returnUrl = returnUrl }));
            }
            else
            {
                SetErrorMessage(MessageConstant.Values.SaveFailed);
            }
            return(View(nameof(Edit), model));
        }
Esempio n. 20
0
 public void UpdateCourt(Court court)
 {
     using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(Helper.CnnVal("TennisklubbenHTKDB")))
     {
         connection.Execute("dbo.spTennisKlubbenHTK_UpdateCourt @CourtId, @Name, @Underlay", court);
     }
 }
        public ActionResult ChooseCourt([Bind(Include = "CourtID,Name")] Court c)
        {
            int    idCourt   = c.CourtID;
            string nameCourt = c.Name;

            return(RedirectToAction("Create", "Advertisement", new { id = idCourt, name = nameCourt }));
        }
Esempio n. 22
0
        public void CreateCourtAndLinkToFacility(int facilityId, ref Court court)
        {
            //Save the court record
            var insertedRowId = _da.Value.Court.Insert(court);

            if (insertedRowId == 0)
            {
                throw new Exception("Failed to create court record");
            }
            else
            {
                court.Id = insertedRowId;
            }

            //Link the court and facility records
            var facilityCourtLink = new LinkObjectMaster()
            {
                MasterLinkId   = facilityId,
                MasterLinkType = LinkType.Facility,
                ChildLinkId    = court.Id,
                ChildLinkType  = LinkType.Court
            };

            //Save the link record
            insertedRowId = _da.Value.Link.Insert(facilityCourtLink);

            if (insertedRowId == 0)
            {
                //Roll back the inserts as it's failed
                //Delete the court record
                _da.Value.Court.Delete(court);

                throw new Exception("Failed to create facility court link record, transaction rolled back");
            }
        }
        // usuwanie kortu
        // sprawdzenie czy nie ma powiązań w innych tabelach jest po stronie bazy
        // przy wywołaniu dać w if'ie, żeby sprawdzić czy na pewno udało się usunąć
        public static bool DeleteCourt(Court court)
        {
            bool result = false;

            using (SqlConnection connection = SqlDatabase.NewConnection())
            {
                if (SqlDatabase.OpenConnection(connection))
                {
                    var command = new SqlCommand("dbo.DeleteCourt", connection);
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.AddWithValue("@CourtID", court.CourtID);

                    command.CommandTimeout = SqlDatabase.Timeout;

                    try
                    {
                        command.ExecuteNonQuery();
                        court.CourtID = 0;
                        result        = true;
                    }
                    catch (Exception ex)
                    {
                    }

                    SqlDatabase.CloseConnection(connection);
                }
            }
            return(result);
        }
Esempio n. 24
0
        public BaseResponse AddCourt(AddCourtRequest request)
        {
            return(ServiceProcessor.ProcessRequest(request,
                                                   //inbound.do validate or do something here
                                                   () =>
            {
            },

                                                   req =>
            {
                var response = new BaseResponse();
                using (var repo = new NhRepository <Court>())
                {
                    var entity = repo.Query(x => x.Name == req.Name).FirstOrDefault();
                    if (entity != null)
                    {
                        throw new EeException(ErrorCodes.Existed, "Object is existed.");
                    }
                    entity = new Court()
                    {
                        Name = req.Name,
                        Province = req.Province,
                        City = req.City,
                        County = req.County,
                        Address = req.Address,
                        Rank = req.Rank,
                        ContactNo = req.ContactNo,
                    };
                    repo.Create(entity);
                }
                return response;
            }
                                                   ));
        }
Esempio n. 25
0
        public static int SaveOrUpdateCourt(Court court)
        {
            lock (DBHelper.Lock)
            {
                if (DBHelper.DBWrapper.IsTableExists <TblCourt>())
                {
                    //var result = GetCourtDetail(court.ID, court.GuId);
                    var result = GetCourtDetail(court.ID);
                    if (result != null && result.Item1 != null)
                    {
                        return(DBHelper.DBWrapper.Update("Update TblCourt set " +
                                                         "Name = ?, IsOccupied =? " +
                                                         "where GuId = ? or ID = ?"
                                                         , new object[] {
                            court.Name,
                            court.IsOccupied,
                            court.GuId, court.ID
                        }));
                    }
                }

                var tblCourtRow = new TblCourt()
                {
                    ID         = court.ID,
                    GuId       = court.GuId,
                    Name       = court.Name,
                    IsOccupied = court.IsOccupied,
                };

                return(DBHelper.DBWrapper.InsertNewRow <TblCourt>(tblCourtRow));
            }
        }
Esempio n. 26
0
        public bool Fill_VAPS_CourtNamesAndDate(Court court, int reportYear, int reportMonth)
        {
            var _reportDate = new DateTime(reportYear, reportMonth, 1);
            var _template   = repo.AllReadonly <ExcelReportTemplate>()
                              .Where(x => x.CourtTypeId == court.CourtType.MainCourtTypeId)
                              .Where(x => x.DateFrom <= _reportDate && (x.DateTo ?? DateTime.MaxValue) >= _reportDate)
                              .FirstOrDefault();

            bool result = false;

            try
            {
                string polugodie = (reportMonth == 6) ? "I полугодие на" : "цялата";
                InsertExcelReportData(court.Id, _template.Id, reportYear, reportMonth, 1, 1, 9, (court.CityName ?? GetCourtCity(court.Label)));
                InsertExcelReportData(court.Id, _template.Id, reportYear, reportMonth, 1, 1, 11, reportMonth.ToString());
                InsertExcelReportData(court.Id, _template.Id, reportYear, reportMonth, 1, 1, 12, $"месеца на {reportYear}г.");
                InsertExcelReportData(court.Id, _template.Id, reportYear, reportMonth, 2, 0, 9, (court.CityName ?? GetCourtCity(court.Label)));
                InsertExcelReportData(court.Id, _template.Id, reportYear, reportMonth, 2, 0, 11, reportMonth.ToString());
                InsertExcelReportData(court.Id, _template.Id, reportYear, reportMonth, 2, 0, 12, $"месеца на {reportYear}г.");
                InsertExcelReportData(court.Id, _template.Id, reportYear, reportMonth, 3, 1, 2, $"Справка за дейността на съдиите във Военно-апелативния съд през {polugodie} {reportYear}г.");
                InsertExcelReportData(court.Id, _template.Id, reportYear, reportMonth, 4, 1, 2, $"Справка за резултатите от върнати обжалвани и протестирани НАКАЗАТЕЛНИТЕ дела на съдиите от { court.CourtType.Label} гр.{(court.CityName ?? GetCourtCity(court.Label))} през {polugodie} {reportYear}г.");

                result = true;
            }
            catch (Exception)
            {
            }
            return(result);
        }
        private void btnSaveCourt_Click(object sender, RoutedEventArgs e)
        {
            if (txtCourtType.Text == "")
            {
                MessageBox.Show("Court Type field must not be Empty", "Error");
                txtCourtType.Focus();
                return;
            }
            if (txtCourtCity.Text == "")
            {
                MessageBox.Show("password field must not be Empty", "Error");
                txtCourtCity.Focus();
                return;
            }

            Court court = new Court();

            court.CourtId   = Guid.NewGuid();
            court.CourtCity = txtCourtCity.Text;
            court.CourtType = txtCourtType.Text;

            if (new CourtDA().insertNewCourt(court))
            {
                MessageBox.Show("Court Successfuly Added to your System");
                this.Close();
            }
            else
            {
                MessageBox.Show("Court Successfuly Added to your System");
            }
        }
Esempio n. 28
0
        public PublicCourtModel(Court court)
        {
            Id   = court.Id;
            Name = court.Name.Sanatize();

            if (court.Substitute != null)
            {
                Status = "Vertreten durch " + court.Substitute.Name;
            }
            else if (court.LastUpdate.AddDays(court.AskPeriodDays + (court.ReminderPeriodDays * 5)) < DateTime.Now)
            {
                Status = "Unbekannt (Keine Rückmeldung)";
            }
            else
            {
                Status = ComputeJudgeStatus(court);

                if (court.LastUpdate.AddDays(court.AskPeriodDays + (court.ReminderPeriodDays * 3)) < DateTime.Now)
                {
                    Status += " (Rückmeldung überfällig)";
                }
                else if (court.LastUpdate.AddDays(court.AskPeriodDays + court.ReminderPeriodDays) < DateTime.Now)
                {
                    Status += " (Rückmeldung erwartet)";
                }
            }

            LoadStatus = court.CaseLoad.Translate();
        }
Esempio n. 29
0
        public IHttpActionResult PutCourt(int id, Court court)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != court.CourtID)
            {
                return(BadRequest());
            }

            db.Entry(court).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CourtExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Esempio n. 30
0
        public ActionResult DeleteConfirmed(int id)
        {
            Court court = db.Courts.Find(id);

            db.Courts.Remove(court.Id);
            return(RedirectToAction("Index", new { id = court.BranchId }));
        }
Esempio n. 31
0
        public Court CreateCourt(Court court)
        {
            db.Courts.AddObject(court);

            SaveChanges();

            return court;
        }
Esempio n. 32
0
 public ActionResult Edit(Court court)
 {
     if (ModelState.IsValid)
     {
         db.Entry(court).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(court);
 }
Esempio n. 33
0
        public static CourtJson FromCourt(Court court)
        {
            CourtJson json = new CourtJson();

            if (null != court)
            {
                json.id = court.CourtId.ToString().Replace("-", "");
                json.name = court.Name;
                json.latitude = court.Latitude.Value;
                json.longitude = court.Longitude.Value;
            }

            return json;
        }
Esempio n. 34
0
        public ActionResult Create(Court court)
        {
            db.Organizations.Attach(SiteContext.CurrentOrganization);

            court.Organization = SiteContext.CurrentOrganization;

            if (ModelState.IsValid)
            {
                db.Courts.Add(court);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(court);
        }
Esempio n. 35
0
        public SaveResult DeleteCourt(Court court)
        {
            SaveResult result = new SaveResult { WasSuccessful = true };

            db.Courts.DeleteObject(court);

            if (!SaveChanges())
            {
                result.WasSuccessful = false;
                result.Message = "Error deleting Court";
            }

            return result;
        }
Esempio n. 36
0
        public SaveResult UpdateCourt(Court court)
        {
            SaveResult result = new SaveResult { WasSuccessful = true };

            db.Courts.Attach(court);

            db.ObjectStateManager.ChangeObjectState(court, System.Data.EntityState.Modified);

            if (!SaveChanges())
            {
                result.WasSuccessful = false;
                result.Message = "Error updating Court";
            }

            return result;
        }
Esempio n. 37
0
        public ActionResult CreateOffer(DateTime date, long[] locations, string courtData, string comments, long? opponentId)
        {
            var fbContext = FacebookWebContext.Current;

            TennisUserModel tennisUser = ModelUtils.GetTennisUsers(this.DB).Where(u => u.FacebookId == fbContext.UserId).FirstOrDefault();

            if (null != tennisUser)
            {
                List<long> pushIds = new List<long>();
                Court court = ProcessCourtData(courtData);

                if (!string.IsNullOrEmpty(courtData))
                {
                    CourtJson courtJson = JsonSerializer.Current.DeserializeObject<CourtJson>(courtData);

                    if (null != courtJson && !string.IsNullOrEmpty(courtJson.name))
                    {
                        court = this.DB.Court.Where(c => c.CourtId == courtJson.GuidId).FirstOrDefault();

                        if (null == court)
                        {
                            court = new Court();
                            court.CourtId = courtJson.GuidId;
                            court.Name = courtJson.name;
                            court.Latitude = courtJson.latitude;
                            court.Longitude = courtJson.longitude;

                            this.DB.Court.InsertOnSubmit(court);
                        }
                    }
                }

                //Add the entry, send out the messages
                Offer offer = new Offer();
                offer.OfferId = Guid.NewGuid();
                offer.FacebookId = tennisUser.FacebookId;
                offer.MatchDateUtc = IndexModel.GetUtcDate(date, tennisUser.TimeZoneOffset);
                offer.PostDateUtc = DateTime.UtcNow;
                offer.Message = comments;
                offer.PreferredLocationId = tennisUser.City.LocationId;
                offer.Court = court;
                // BUGBUG: we dont' seem to set the completed flag anywhere currently
                offer.Completed = false;

                User opponent = null;

                if (opponentId.HasValue && opponentId.Value != 0)
                {
                    opponent = this.DB.User.Where(u => u.FacebookId == opponentId.Value).FirstOrDefault();
                }

                if (null != opponent)
                {
                    offer.SpecificOpponentId = opponent.FacebookId;
                    pushIds.Add(opponent.FacebookId);
                }
                else
                {
                    var tennisUsers = ModelUtils.GetTennisUsers(this.DB);
                    var matchUsers = tennisUsers.Where
                    (u =>
                        this.DB.CoordinateDistanceMiles(u.City.Latitude, u.City.Longitude, tennisUser.City.Latitude, tennisUser.City.Longitude) < 15 &&
                        Math.Abs(tennisUser.Rating - u.Rating) <= 0.25 &&
                        u.Gender == tennisUser.Gender &&
                        u.FacebookId != tennisUser.FacebookId &&
                        u.EmailOffers
                    );

                    foreach (var tu in matchUsers)
                    {
                        pushIds.Add(tu.FacebookId);
                    }
                }

                this.DB.Offer.InsertOnSubmit(offer);
                this.DB.SubmitChanges();

                string template = Server.MapPath("/content/matchrequest.htm");
                string subject = string.Format("TennisLoop: Match Requested from <fb:name uid='{0}' capitalize='true'></fb:name>", tennisUser.FacebookId);
                SendMessage(pushIds, subject, template, offer, tennisUser);

                // Send out messages to all matching users

                return Json
                (
                    new
                    {
                        UserOffers = RenderPartialViewToString("UserOffers", ModelUtils.GetModel<UserOffersModel>(FacebookWebContext.Current.UserId, this.DB)),
                        UserChallenges = RenderPartialViewToString("UserChallenges", ModelUtils.GetModel<UserOffersModel>(FacebookWebContext.Current.UserId, this.DB))
                    }
                 );
            }

            return Json("");
        }
Esempio n. 38
0
        private Court ProcessCourtData(string courtData)
        {
            Court court = null;

            if (!string.IsNullOrEmpty(courtData))
            {
                CourtJson courtJson = JsonSerializer.Current.DeserializeObject<CourtJson>(courtData);

                if (null != courtJson && !string.IsNullOrEmpty(courtJson.name))
                {
                    court = this.DB.Court.Where(c => c.CourtId == courtJson.GuidId).FirstOrDefault();

                    if (null == court)
                    {
                        court = new Court();
                        court.CourtId = courtJson.GuidId;
                        court.Name = courtJson.name;
                        court.Latitude = courtJson.latitude;
                        court.Longitude = courtJson.longitude;

                        this.DB.Court.InsertOnSubmit(court);
                    }
                }
            }

            return court;
        }