Ejemplo n.º 1
0
        public SeasonModel GetSeasonAndMapToCategoryModel(int?seasonid)
        {
            SeasonModel seasonModel = null;

            try
            {
                if (seasonid != null)
                {
                    using (var db = new Entities())
                    {
                        var season = db.Seasons.SingleOrDefault(i => i.SeasonID == seasonid);
                        if (season != null)
                        {
                            var stream     = new MemoryStream(ASCIIEncoding.Default.GetBytes(season.Name));
                            var serializer = new DataContractJsonSerializer(typeof(MultiLingualListModel));
                            var jsonResult = (MultiLingualListModel)serializer.ReadObject(stream);

                            seasonModel = new SeasonModel
                            {
                                SeasonID = season.SeasonID,
                                Name     = jsonResult
                            };
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.ErrorFormat("GetSeasonAndMapToCategoryModel - error [{0}] - - \r\n {1} \r\n\r\n", ex.Message, ex.StackTrace);
            }

            return(seasonModel);
        }
Ejemplo n.º 2
0
        public SeasonViewModel()
        {
            SeasonModel sm      = new SeasonModel();
            DataTable   seasons = sm.All();

            Seasons = sm.GiveCollection(seasons);
        }
Ejemplo n.º 3
0
        public async Task PutSeason_WhenSeasonIsFoundAndNotSaved_ShouldReturnBadRequestResult()
        {
            // Arrange
            var    seasonRepository = A.Fake <ISeasonRepository>();
            Season?season           = new Season();

            A.CallTo(() => seasonRepository.GetSeasonAsync(A <int> .Ignored)).Returns(season);

            var sharedRepository = A.Fake <ISharedRepository>();

            A.CallTo(() => sharedRepository.SaveChangesAsync()).Returns(0);

            var mapper      = A.Fake <IMapper>();
            var returnModel = new SeasonModel();

            A.CallTo(() => mapper.Map <SeasonModel>(season)).Returns(returnModel);

            var linkGenerator = A.Fake <LinkGenerator>();

            var testController = new SeasonsController(seasonRepository, sharedRepository, mapper, linkGenerator);

            int id    = 1;
            var model = new SeasonModel();

            // Act
            var result = await testController.PutSeason(id, model);

            // Assert
            A.CallTo(() => seasonRepository.GetSeasonAsync(id)).MustHaveHappenedOnceExactly();
            A.CallTo(() => mapper.Map(model, season)).MustHaveHappenedOnceExactly();
            A.CallTo(() => sharedRepository.SaveChangesAsync()).MustHaveHappenedOnceExactly();
            A.CallTo(() => mapper.Map <SeasonModel>(season)).MustNotHaveHappened();
            result.Result.ShouldBeOfType <BadRequestResult>();
        }
Ejemplo n.º 4
0
        public ViewReceiptViewModel(ReceiptModel receipt, bool customer_fixed = false)
        {
            Receipt = receipt;
            // Fill Customers
            CustomerModel customers = new CustomerModel();
            DataTable     cs        = customers.All();

            Customers = customers.GiveCollection(cs);
            // Fill Seasons
            SeasonModel sm = new SeasonModel();
            DataTable   ss = sm.All();

            Seasons = sm.GiveCollection(ss);
            //Fill Currencies
            CurrencyModel currency = new CurrencyModel();
            DataTable     cc       = currency.All();

            Currencies = currency.GiveCollection(cc);
            FillForm(cs, ss, cc);
            Enabled         = false;
            MainButtonText  = "Enable Editing";
            FactureChanged  = false;
            IsCustomerFixed = customer_fixed;
            if (customer_fixed == false)
            {
                IsCustomerEnabled = Enabled;
            }
            else
            {
                IsCustomerEnabled = false;
            }
        }
Ejemplo n.º 5
0
 private void FillCombos()
 {
     if (Facture.Season.ToString() != null)
     {
         Season = new SeasonModel();
         Season = Season.Get(Facture.Season);
         for (int i = 0; i < Seasons.Count(); i++)
         {
             if (Season.Id == Seasons[i].Id)
             {
                 SelectedSeason = i;
                 break;
             }
         }
     }
     else
     {
         SelectedSeason = null;
     }
     Customer = new CustomerModel();
     Customer = Customer.Get(Facture.Customer);
     for (int i = 0; i < Customers.Count(); i++)
     {
         if (Customer.Id == Customers[i].Id)
         {
             SelectedCustomer = i;
             break;
         }
     }
 }
        private void SeasonComboBox_SelectedValueChanged(object sender, EventArgs e)
        {
            SeasonModel sm = (SeasonModel)SeasonComboBox.SelectedItem;

            divs = GlobalConfig.Connection.GetSeasonDivisions(sm.SeasonID);
            WireupDivisionSelector();
        }
Ejemplo n.º 7
0
        private void seasons_mouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            SeasonModel season = list_seasons.SelectedItem as SeasonModel;

            list_episodes.ItemsSource = season.Episodes;
            list_episodes.Items.Refresh();
        }
Ejemplo n.º 8
0
        public CreateReceiptViewModel(ReceiptModel receipt = null)
        {
            // Fill Customers
            CustomerModel customers = new CustomerModel();

            Customers = customers.GiveCollection(customers.All());
            // Fill Seasons
            SeasonModel sm = new SeasonModel();

            Seasons = sm.GiveCollection(sm.All());
            //Fill Currencies
            CurrencyModel currency = new CurrencyModel();

            Currencies = currency.GiveCollection(currency.All());
            Delivery   = DateTime.UtcNow.Date;
            if (receipt != null)
            {
                for (int i = 0; i < Customers.Count; i++)
                {
                    int id1 = Customers[i].Id;
                    int id2 = (int)receipt.Customer;
                    if (id1 == id2)
                    {
                        Customer = Customers[i];
                        break;
                    }
                }
                IsEnabled = false;
            }
            else
            {
                IsEnabled = true;
            }
        }
Ejemplo n.º 9
0
        public SeasonModel Edit(SeasonModel seasonModel)
        {
            var         body       = JsonConvert.SerializeObject(seasonModel);
            SeasonModel SeasonEdit = ServerResponse.Invoke <SeasonModel>("api/season/edit?id=" + seasonModel.Id, body, "POST");

            return(SeasonEdit);
        }
Ejemplo n.º 10
0
        public SeasonModel Delete(SeasonModel seasonModel)
        {
            var         body         = JsonConvert.SerializeObject(seasonModel);
            SeasonModel SeasonDelete = ServerResponse.Invoke <SeasonModel>("api/season/Delete?id=" + seasonModel.Id, body, "POST");

            return(SeasonDelete);
        }
Ejemplo n.º 11
0
        public async Task <ActionResult <Season> > PostSeason(SeasonModel model)
        {
            try
            {
                var location = _linkGenerator.GetPathByAction("GetSeason", "Seasons", new { id = -1 });
                if (string.IsNullOrWhiteSpace(location))
                {
                    return(BadRequest("Could not use ID"));
                }

                var season = _mapper.Map <Season>(model);

                await _seasonRepository.AddAsync(season);

                if (await _sharedRepository.SaveChangesAsync() > 0)
                {
                    return(Created(location, _mapper.Map <SeasonModel>(season)));
                }
            }
            catch (Exception)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, Settings.DatabaseFailureString));
            }

            return(BadRequest());
        }
Ejemplo n.º 12
0
 /// <summary>
 /// Creates a new empty season.
 /// </summary>
 public Season(SeasonModel givenModel)
 {
     this.model          = givenModel;
     this.gameDays       = new List <GameDay>();
     this.gameDayPointer = 0;
     this.state          = SeasonState.NotStarted;
 }
Ejemplo n.º 13
0
        public SeasonModel GetById(int?id)
        {
            var         body       = "";
            SeasonModel SeasonById = ServerResponse.Invoke <SeasonModel>("api/season/getDetail?id=" + id, body, "get");

            return(SeasonById);
        }
Ejemplo n.º 14
0
        public async Task GetSeason_WhenSeasonIsNotNull_ShouldReturnSeasonModelOfDesiredSeason()
        {
            // Arrange
            var    seasonRepository = A.Fake <ISeasonRepository>();
            Season?season           = new Season();

            A.CallTo(() => seasonRepository.GetSeasonAsync(A <int> .Ignored)).Returns(season);

            var sharedRepository = A.Fake <ISharedRepository>();

            var         mapper      = A.Fake <IMapper>();
            SeasonModel?seasonModel = new SeasonModel();

            A.CallTo(() => mapper.Map <SeasonModel>(A <Season> .Ignored)).Returns(seasonModel);

            var linkGenerator = A.Fake <LinkGenerator>();

            var testController = new SeasonsController(seasonRepository, sharedRepository, mapper, linkGenerator);

            int id = 1;

            // Act
            var result = await testController.GetSeason(id);

            // Assert
            A.CallTo(() => seasonRepository.GetSeasonAsync(id)).MustHaveHappenedOnceExactly();
            A.CallTo(() => mapper.Map <SeasonModel>(season)).MustHaveHappenedOnceExactly();
            result.Value.ShouldBeOfType <SeasonModel>();
        }
Ejemplo n.º 15
0
        public async Task GetSeason_WhenExceptionIsCaught_ShouldReturnInternalServerError()
        {
            // Arrange
            var    seasonRepository = A.Fake <ISeasonRepository>();
            Season?season           = new Season();

            A.CallTo(() => seasonRepository.GetSeasonAsync(A <int> .Ignored)).Throws <Exception>();

            var sharedRepository = A.Fake <ISharedRepository>();

            var         mapper      = A.Fake <IMapper>();
            SeasonModel?seasonModel = new SeasonModel();

            A.CallTo(() => mapper.Map <SeasonModel>(A <Season> .Ignored)).Returns(seasonModel);

            var linkGenerator = A.Fake <LinkGenerator>();

            var testController = new SeasonsController(seasonRepository, sharedRepository, mapper, linkGenerator);

            int id = 1;

            // Act
            var result = await testController.GetSeason(id);

            // Assert
            result.Result.ShouldBeOfType <ObjectResult>();
            ((ObjectResult)result.Result).StatusCode.ShouldBe(StatusCodes.Status500InternalServerError);
            ((ObjectResult)result.Result).Value.ShouldBe("Database failure");
        }
Ejemplo n.º 16
0
        public async Task PutSeason_WhenSeasonIsNotFound_ShouldReturnNotFoundResult()
        {
            // Arrange
            var    seasonRepository = A.Fake <ISeasonRepository>();
            Season?season           = null;

            A.CallTo(() => seasonRepository.GetSeasonAsync(A <int> .Ignored)).Returns(season);

            var sharedRepository = A.Fake <ISharedRepository>();
            var mapper           = A.Fake <IMapper>();
            var linkGenerator    = A.Fake <LinkGenerator>();

            var testController = new SeasonsController(seasonRepository, sharedRepository, mapper, linkGenerator);

            int id    = 1;
            var model = new SeasonModel();

            // Act
            var result = await testController.PutSeason(id, model);

            // Assert
            A.CallTo(() => seasonRepository.GetSeasonAsync(id)).MustHaveHappenedOnceExactly();
            result.Result.ShouldBeOfType <NotFoundObjectResult>();
            ((NotFoundObjectResult)result.Result).Value.ShouldBe($"Could not find season with ID of {id}");
        }
Ejemplo n.º 17
0
    public UiLevelItem Setup(SeasonModel season, int index, bool enabled)
    {
        numberLabel.text = GlobalFactory.Seasons.GetLevelNumber(season.id, index + 1).ToString();
        var earnstars = Profile.GetLevelStars(season.id, index);

        for (int i = 0; i < stars.Length; i++)
        {
            stars[i].SetActive(earnstars > i);
        }
        if (enabled && earnstars < 1)
        {
            animator.Play();
        }

        if (GlobalConfig.DebugMode == false)
        {
            button.SetInteractable(enabled);
        }

        button.onClick.AddListener(() =>
        {
            if (Profile.Hearts > 0)
            {
                Game.Instance.OpenPopup <Popup_LevelInfo>().Setup(season, index, true);
            }
            else
            {
                Game.Instance.OpenPopup <Popup_BuyHearts>();
            }
        });

        return(this);
    }
Ejemplo n.º 18
0
        public bool CheckSeasonCode(SeasonModel seasonModel)
        {
            var body            = JsonConvert.SerializeObject(seasonModel);
            var CheckSeasonCode = ServerResponse.Invoke <bool>("api/season/checkSeasonCode", body, "POST");

            return(CheckSeasonCode);
        }
Ejemplo n.º 19
0
        public bool Create(SeasonModel seasonModel)
        {
            var  body         = JsonConvert.SerializeObject(seasonModel);
            bool SeasonCreate = ServerResponse.Invoke <bool>("api/season/create", body, "Post");

            return(SeasonCreate);
        }
Ejemplo n.º 20
0
        public async Task <ActionResult <SeasonModel> > PutSeason(int id, SeasonModel model)
        {
            try
            {
                var season = await _seasonRepository.GetSeasonAsync(id);

                if (season is null)
                {
                    return(NotFound($"Could not find season with ID of {id}"));
                }

                _mapper.Map(model, season);

                if (await _sharedRepository.SaveChangesAsync() > 0)
                {
                    return(_mapper.Map <SeasonModel>(season));
                }
            }
            catch (Exception)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, Settings.DatabaseFailureString));
            }

            return(BadRequest());
        }
Ejemplo n.º 22
0
 /*
  * Constructor
  */
 #region
 public BalanceViewModel(CustomerModel customer = null, SeasonModel season = null, CurrencyModel currency = null, Boolean seasoned_factures = true)
 {
     SeasondFactures = seasoned_factures;
     Customer        = customer;
     Season          = season;
     Currency        = currency;
     SetBalance();
 }
Ejemplo n.º 23
0
        public ActionResult DeleteConfirmed(int id)
        {
            SeasonModel seasonModel = db.Seasons.Find(id);

            db.Seasons.Remove(seasonModel);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 24
0
        public async Task <ActionResult <Season> > Post(SeasonModel model)
        {
            var item = _mapper.Map <Season>(model);

            _context.Seasons.Add(item);
            await _context.SaveChangesAsync();

            return(CreatedAtAction(nameof(Get), new { id = item.Id }, _mapper.Map <SeasonViewModel>(item)));
        }
Ejemplo n.º 25
0
 public ActionResult Edit([Bind(Include = "SeasonId,SeasonName")] SeasonModel seasonModel)
 {
     if (ModelState.IsValid)
     {
         db.Entry(seasonModel).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(seasonModel));
 }
Ejemplo n.º 26
0
 public ActionResult Edit(SeasonModel season)
 {
     if (ModelState.IsValid)
     {
         SeasonModel Edit = Services.SeasonService.Edit(season);
         TempData["Success"] = "Data saved successfully!";
         return(RedirectToAction("Index", "Season"));
     }
     return(View(season));
 }
Ejemplo n.º 27
0
 public ActionResult DeleteConfirmed(SeasonModel season)
 {
     if (season.Id > 0)
     {
         SeasonModel UserDelete = Services.SeasonService.Delete(season);
         TempData["Success"] = "Data saved successfully!";
         return(RedirectToAction("Index", "Season"));
     }
     return(View(season));
 }
Ejemplo n.º 28
0
        public ActionResult EditSeason(SeasonModel model)
        {
            if (DbAccess.SaveSeason(model.SeasonId.GetValueOrDefault(), model.SeasonName, model.LodgingId.GetValueOrDefault(),
                                    model.StartDate, model.EndDate, model.SeasonTypeId.GetValueOrDefault(), model.Deadline))
            {
                return(Json(new { success = true }, JsonRequestBehavior.DenyGet));
            }


            return(Json(new { success = false }, JsonRequestBehavior.DenyGet));;
        }
Ejemplo n.º 29
0
        public ActionResult Create([Bind(Include = "SeasonId,SeasonName")] SeasonModel seasonModel)
        {
            if (ModelState.IsValid)
            {
                db.Seasons.Add(seasonModel);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(seasonModel));
        }
Ejemplo n.º 30
0
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            SeasonModel SeasonModelById = Services.SeasonService.GetById(id);

            return(View(SeasonModelById));
        }