Beispiel #1
0
 public ActionResult Edit(SchoolViewModel viewModel)
 {
     if (ModelState.IsValid)
     {
         var board = _repository.Project <School, bool>(schools => (from s in schools where s.SchoolId == viewModel.SchoolId select s).Any());
         if (!board)
         {
             _logger.Warn(string.Format("School not exists '{0}'.", viewModel.Name));
             Danger(string.Format("School not exists '{0}'.", viewModel.Name));
         }
         var result = _schoolService.Update(new School
         {
             SchoolId     = viewModel.SchoolId,
             Name         = viewModel.Name,
             CenterNumber = viewModel.CenterNumber == null ? "" : viewModel.CenterNumber.Trim(),
         });
         if (result.Success)
         {
             var roleUserId  = User.Identity.GetUserId();
             var roles       = _aspNetRolesService.GetCurrentUserRole(roleUserId);
             var bodySubject = "Web portal changes - School update";
             var message     = "School Updated Successfully";
             SendMailToAdmin(roles, roleUserId, message, viewModel.Name, bodySubject);
             Success(result.Results.FirstOrDefault().Message);
             ModelState.Clear();
             return(RedirectToAction("Index"));
         }
         else
         {
             _logger.Warn(result.Results.FirstOrDefault().Message);
             Warning(result.Results.FirstOrDefault().Message, true);
         }
     }
     return(View(viewModel));
 }
Beispiel #2
0
        public ActionResult Create(SchoolViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                var school = new School
                {
                    CenterNumber = viewModel.CenterNumber,
                    Name         = viewModel.Name
                };
                var result = _schoolService.Save(school);
                if (result.Success)
                {
                    var roleUserId  = User.Identity.GetUserId();
                    var roles       = _aspNetRolesService.GetCurrentUserRole(roleUserId);
                    var bodySubject = "Web portal changes - School Create";
                    var message     = "School Created Successfully";
                    SendMailToAdmin(roles, roleUserId, message, viewModel.Name, bodySubject);
                    Success(result.Results.FirstOrDefault().Message);
                    ModelState.Clear();
                    viewModel = new SchoolViewModel();
                }
                else
                {
                    _logger.Warn(result.Results.FirstOrDefault().Message);
                    Warning(result.Results.FirstOrDefault().Message, true);
                }
            }

            viewModel = new SchoolViewModel();

            return(View(viewModel));
        }
Beispiel #3
0
        /////////////////////////////////////
        // PUT - update school data based on Id
        public IHttpActionResult PutSchool(SchoolViewModel school)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("Invalid Data. Please Check again"));
            }

            using (var x = new TestSHEntities())
            {
                var checkExistingSchool = x.Schools.Where(c => c.RawID == school.RawID)
                                          .FirstOrDefault <School>();

                if (checkExistingSchool != null)
                {
                    checkExistingSchool.SchoolID    = school.SchoolID;
                    checkExistingSchool.School_Name = school.School_Name;
                    checkExistingSchool.City        = school.City;
                    checkExistingSchool.Directorate = school.Directorate;
                    checkExistingSchool.Lat         = school.Lat;
                    checkExistingSchool.Long        = school.Long;
                    x.SaveChanges();
                }
                else
                {
                    return(NotFound());
                }
            }
            return(Ok());
        }
        public IActionResult Update(SchoolViewModel model)
        {
            var school = _mapper.Map <SchoolViewModel, School>(model);

            _balSchool.Update(school);
            return(RedirectToAction("Index", "Schools"));
        }
Beispiel #5
0
        public async Task <Tuple <bool, string, SchoolViewModel> > GetSchoolIDOrUserName(string DcIDorName)
        {
            Tuple <bool, string, SchoolViewModel> result = null;
            SchoolViewModel schoolDetails = new SchoolViewModel();

            try
            {
                var parameters = new DynamicParameters();
                using (SqlConnection con = new SqlConnection(_dcDb))
                {
                    parameters.Add("@DcIDorName", DcIDorName, DbType.String);
                    using (var multi = await con.QueryMultipleAsync("dbo.Select_SchoolIDandName", parameters, commandType: CommandType.StoredProcedure))
                    {
                        schoolDetails = multi.Read <SchoolViewModel>().Single();
                    }
                }

                if (schoolDetails != null)
                {
                    result = Tuple.Create(true, "", schoolDetails);
                }
                else
                {
                    result = Tuple.Create(false, "No records found", schoolDetails);
                }
            }
            catch (Exception ex)
            {
                ErrorLog.Write(ex);
                result = Tuple.Create(false, "", schoolDetails);
            }
            return(result);
        }
        public SelectedStudentDetailPage()
        {
            InitializeComponent();

            // Set BindingContext.
            BindingContext = new SchoolViewModel();
        }
        public IActionResult Edit(int id, SchoolViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            School school = _repos.Schools.Get(id);

            if (school == null)
            {
                return(NotFound("School with that id can't be edited since it does not exist."));
            }
            else
            {
                var reflectResult = school.UpdateReflector(model);

                if (reflectResult.TotalUpdates < 1)
                {
                    return(NoContent());
                }
                else
                {
                    school = _repos.Schools.Update(reflectResult.Value);

                    return(Ok(school));
                }
            }
        }
Beispiel #8
0
        //public List<Schools> getAllSchools(opensisContext context)
        public SchoolListViewModel getAllSchools(SchoolViewModel objModel)
        {
            logger.Info("Method getAllSchools called.");
            SchoolListViewModel schoolList = new SchoolListViewModel();

            try
            {
                if (TokenManager.CheckToken(objModel._tenantName, objModel._token))
                {
                    List <Schools> schools = this.schoolRepository.GetAllSchools();
                    schoolList.schoolList = schools;
                    schoolList._message   = SUCCESS;
                    schoolList._failure   = false;
                    logger.Info("Method getAllSchools end with success.");
                }
                else
                {
                    schoolList._failure = true;
                    schoolList._message = TOKENINVALID;
                }
            }
            catch (Exception ex)
            {
                schoolList._message = ex.Message;
                schoolList._failure = true;
                logger.Error("Method getAllSchools end with error :" + ex.Message);
            }


            return(schoolList);
        }
        public async Task UpdateAsync(SchoolViewModel model)
        {
            var dbSport = await _repo.Schools.GetByIdAsync(model.Id);

            if (model.ProfileBlob != dbSport.ProfileBlob)
            {
                //delete current one
                new AzureStorage(dbSport.ProfileContainer, true).DeleteFile(dbSport.ProfileContainer);
            }
            if (model.IsActive == false)
            {
                var teams = await _repo.Teams.Where(m => m.SchoolId == model.Id && m.DateDeletedUtc == null).ToListAsync();

                foreach (var team in teams)
                {
                    team.IsActive = false;
                }
                var feeds = await _repo.RssFeeds.Where(m => m.SchoolId == model.Id && m.DateDeletedUtc == null).ToListAsync();

                foreach (var feed in feeds)
                {
                    feed.IsActive = false;
                }
            }
            await _repo.SaveAsync();

            await _repo.Schools.AddOrUpdateAndSaveAsync(MapAddUpdate(true).CreateMapper().Map(model, dbSport));
        }
        public PartialViewResult UpdateBenchmarkBasketAddMultiple(string[] urns)
        {
            HttpCookie cookie = null;

            foreach (var urn in urns)
            {
                var benchmarkSchool = new SchoolViewModel(_contextDataService.GetSchoolByUrn(urn), null);

                cookie = base.UpdateSchoolComparisonListCookie(CompareActions.ADD_TO_COMPARISON_LIST,
                                                               new BenchmarkSchoolViewModel()
                {
                    Name          = benchmarkSchool.Name,
                    Urn           = benchmarkSchool.Id,
                    Type          = benchmarkSchool.Type,
                    FinancialType = benchmarkSchool.FinancialType.ToString()
                });
            }

            if (cookie != null)
            {
                Response.Cookies.Add(cookie);
            }

            return(PartialView("Partials/BenchmarkListBanner",
                               new SchoolViewModel(null, base.ExtractSchoolComparisonListFromCookie())));
        }
        public PartialViewResult UpdateBenchmarkBasket(int?urn, string withAction)
        {
            HttpCookie cookie;

            if (urn.HasValue)
            {
                var benchmarkSchool = new SchoolViewModel(_contextDataService.GetSchoolByUrn(urn.ToString()), null);

                cookie = base.UpdateSchoolComparisonListCookie(withAction,
                                                               new BenchmarkSchoolViewModel()
                {
                    Name          = benchmarkSchool.Name,
                    Urn           = benchmarkSchool.Id,
                    Type          = benchmarkSchool.Type,
                    FinancialType = benchmarkSchool.FinancialType.ToString()
                });
            }
            else
            {
                cookie = base.UpdateSchoolComparisonListCookie(withAction, null);
            }

            if (cookie != null)
            {
                Response.Cookies.Add(cookie);
            }

            return(PartialView("Partials/BenchmarkBasketControls", base.ExtractSchoolComparisonListFromCookie()));
        }
        public void BuildShouldApplyUrbanRuralToCriteria()
        {
            dynamic model = new EdubaseDataObject();

            model.NumberOfPupils = 100;

            var financeObj = new SchoolTrustFinancialDataObject();

            financeObj.NoPupils             = 100;
            financeObj.OverallPhase         = "Secondary";
            financeObj.UrbanRural           = "Urban and city";
            financeObj.PercentageFSM        = 100;
            financeObj.PercentagePupilsWSEN = 100;
            financeObj.PercentagePupilsWEAL = 100;
            financeObj.LA = 831;

            var benchmarkSchool = new SchoolViewModel(model);

            benchmarkSchool.HistoricalFinancialDataModels = new List <FinancialDataModel>();
            benchmarkSchool.HistoricalFinancialDataModels.Add(new FinancialDataModel("123", "2014-2015", financeObj, EstablishmentType.Maintained));

            var builder = new BenchmarkCriteriaBuilderService();

            var criteria = builder.BuildFromSimpleComparisonCriteria(benchmarkSchool.HistoricalFinancialDataModels.Last(), true, true, true, true, 0);

            Assert.AreEqual(financeObj.UrbanRural, criteria.UrbanRural[0]);
        }
Beispiel #13
0
        public ActionResult Crear(SchoolViewModel schoolViewModel)
        {
            if (User.Identity.IsAuthenticated)
            {
                if (Int32.Parse(User.Identity.Name.Split(',')[1]) == 1)
                {
                    var existingSchool = from school in db.Schools where school.SchoolSequenceNumber == schoolViewModel.School.SchoolSequenceNumber && school.DeletionDate == null select school;

                    if (existingSchool.Count() != 0)
                    {
                        ModelState.AddModelError("", Resources.WebResources.School_SchoolSequenceNumber_Unique);
                    }

                    if (ModelState.IsValid)
                    {
                        schoolViewModel.School.UpdateDate = DateTime.Now;
                        schoolViewModel.School.CreateDate = DateTime.Now;

                        schoolViewModel.School.CreateUser = Int32.Parse(User.Identity.Name.Split(',')[0]);
                        schoolViewModel.School.UpdateUser = Int32.Parse(User.Identity.Name.Split(',')[0]);

                        db.Schools.Add(schoolViewModel.School);
                        db.SaveChanges();

                        return(View("_Hack"));
                    }
                    return(Content(GetErrorsFromModelState(schoolViewModel)));
                }
            }
            return(RedirectToAction("AccesoDenegado", "Home"));
        }
Beispiel #14
0
        public ActionResult PopUpEditar(int id = 0)
        {
            if (User.Identity.IsAuthenticated)
            {
                if (Int32.Parse(User.Identity.Name.Split(',')[1]) == 1)
                {
                    HomeController controller = new HomeController();

                    SchoolViewModel schoolViewModel = new SchoolViewModel
                    {
                        School        = db.Schools.Find(id),
                        Towns         = controller.getTowns(),
                        SchoolRegions = getSchoolRegions()
                    };

                    if (schoolViewModel.School == null)
                    {
                        return(HttpNotFound());
                    }

                    return(PartialView("Editar", schoolViewModel));
                }
            }
            return(RedirectToAction("AccesoDenegado", "Home"));
        }
Beispiel #15
0
        /// <summary>
        /// Step 1 - Advanced
        /// </summary>
        /// <param name="urn"></param>
        /// <param name="comparisonType"></param>
        /// <param name="estType"></param>
        /// <returns></returns>
        public async Task <ViewResult> SelectSchoolType(long?urn, long?fuid, ComparisonType comparisonType, EstablishmentType?estType, int?basketSize)
        {
            ViewBag.URN            = urn;
            ViewBag.Fuid           = fuid;
            ViewBag.ComparisonType = comparisonType;
            ViewBag.EstType        = estType;
            ViewBag.BasketSize     = basketSize;

            if (fuid.HasValue)
            {
                var benchmarkSchool = new FederationViewModel(await _contextDataService.GetSchoolDataObjectByUrnAsync(fuid.Value), _benchmarkBasketService.GetSchoolBenchmarkList());
                _benchmarkBasketService.SetFederationAsDefault(benchmarkSchool);
                return(View("SelectSchoolType", benchmarkSchool));
            }
            else if (urn.HasValue)
            {
                var benchmarkSchool = new SchoolViewModel(await _contextDataService.GetSchoolDataObjectByUrnAsync(urn.Value), _benchmarkBasketService.GetSchoolBenchmarkList());

                return(View("SelectSchoolType", benchmarkSchool));
            }
            else
            {
                _benchmarkBasketService.UnsetDefaultSchool();
                return(View("SelectSchoolType", new SchoolViewModelWithNoDefaultSchool()));
            }
        }
        public SelectedStudentDetailPage()
        {
            InitializeComponent();

            // Set BindingContext.
            BindingContext = new SchoolViewModel();
        }
Beispiel #17
0
        private SchoolListViewModel GetSchoolViewModelList(dynamic response, string orderBy, int page)
        {
            var schoolListVm = new List <SchoolViewModel>();
            var vm           = new SchoolListViewModel(schoolListVm, null, orderBy);

            if (response != null)
            {
                foreach (var result in response.Results)
                {
                    var schoolVm = new SchoolViewModel(result);
                    schoolListVm.Add(schoolVm);
                }

                vm.SchoolComparisonList = base.ExtractSchoolComparisonListFromCookie();

                var filters = _filterBuilder.ConstructTrustSchoolSearchFilters(Request.QueryString, response.Facets);
                vm.Filters = filters;
                vm.FilterSelectionState = DetermineSelectionState(filters);

                vm.Pagination = new Pagination
                {
                    Start             = (SearchDefaults.TRUST_SCHOOLS_PER_PAGE * (page - 1)) + 1,
                    Total             = response.NumberOfResults,
                    PageLinksPerPage  = SearchDefaults.LINKS_PER_PAGE,
                    MaxResultsPerPage = SearchDefaults.TRUST_SCHOOLS_PER_PAGE
                };
            }

            return(vm);
        }
Beispiel #18
0
        private void LoadMasterFile()
        {
            var provider = new ExcelProvider();
            var sheet    = this.shellViewModel.Sheets.SelectedItem;

            if (sheet != null)
            {
                var schools = provider.Read(this.shellViewModel.MasterFilePath, sheet.Name);

                var distinct = (from s in schools
                                orderby s.SchoolFullName
                                select s).DistinctBy(s => s.SchoolFullName);

                this.shellViewModel.Schools.Clear();
                this.shellViewModel.FilteredSchools.Clear();

                foreach (var school in distinct)
                {
                    var viewModel = new SchoolViewModel(school);
                    this.shellViewModel.Schools.Add(viewModel);
                    this.shellViewModel.FilteredSchools.Add(viewModel);
                }
            }

            this.shellViewModel.ApplyFilter();
        }
Beispiel #19
0
        public HttpResponseMessage Update(HttpRequestMessage request, SchoolViewModel school)
        {
            return(CreateHttpResponse(request, () =>
            {
                HttpResponseMessage response = null;

                if (!ModelState.IsValid)
                {
                    response = request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
                }
                else
                {
                    var classDb = _schoolRepository.GetSingle(school.Id);
                    if (classDb == null)
                    {
                        response = request.CreateErrorResponse(HttpStatusCode.NotFound, "Invalid class.");
                    }
                    else
                    {
                        classDb.UpdateSchool(school);
                        _schoolRepository.Edit(classDb);

                        _unitOfWork.Commit();
                        response = request.CreateResponse(HttpStatusCode.OK, school);
                    }
                }

                return response;
            }));
        }
Beispiel #20
0
        public ActionResult Removidos(string requested)
        {
            if (User.Identity.IsAuthenticated)
            {
                if (Int32.Parse(User.Identity.Name.Split(',')[1]) == 1 && Boolean.Parse(requested))
                {
                    var schools = (from school in db.Schools where school.DeletionDate != null select school).ToList();

                    SchoolViewModel schoolViewModel = new SchoolViewModel
                    {
                        Information = new List <UserInfoViewModel>()
                    };

                    foreach (var school in schools)
                    {
                        schoolViewModel.Information.Add(new UserInfoViewModel
                        {
                            School     = school,
                            CreateUser = db.UserDetails.First(sch => sch.UserID == school.CreateUser),
                            UpdateUser = db.UserDetails.First(sch => sch.UserID == school.UpdateUser)
                        });
                    }

                    return(PartialView("Removidos", schoolViewModel));
                }
            }

            return(RedirectToAction("AccesoDenegado", "Home"));
        }
Beispiel #21
0
        public ActionResult SchoolTest()
        {
            var schools = db.Schools.ToList();
            List <SchoolViewModel> lista = new List <SchoolViewModel>();

            foreach (var school in schools)
            {
                int points = 0;

                var classes = db.SchoolClasses.Where(c => c.SchoolId == school.Id).ToList();
                foreach (var myClass in classes)
                {
                    var recycles = db.Recycles.Include(t => t.RecycleType)
                                   .Where(c => c.SchoolClassId == myClass.Id);


                    foreach (var item in recycles)
                    {
                        points += item.Units * item.RecycleType.Points;
                    }
                }

                var viewModel = new SchoolViewModel
                {
                    School = school,
                    Points = points
                };
                lista.Add(viewModel);
            }

            return(View(lista));
        }
Beispiel #22
0
        public SchoolPage()
        {
            InitializeComponent();

            // Set BindingContext.
            BindingContext = new SchoolViewModel();
        }
        public void BuildShouldApplyPercentageMarginForNumberOfPupils()
        {
            dynamic model = new EdubaseDataObject();

            model.NumberOfPupils = 100;

            var financeObj = new SchoolTrustFinancialDataObject();

            financeObj.NoPupils             = 100;
            financeObj.OverallPhase         = "Secondary";
            financeObj.UrbanRural           = "Urban and city";
            financeObj.PercentageFSM        = 100;
            financeObj.PercentagePupilsWSEN = 100;
            financeObj.PercentagePupilsWEAL = 100;
            financeObj.LA = 831;

            var benchmarkSchool = new SchoolViewModel(model);

            benchmarkSchool.HistoricalFinancialDataModels = new List <FinancialDataModel>();
            benchmarkSchool.HistoricalFinancialDataModels.Add(new FinancialDataModel("123", "2014-2015", financeObj, EstablishmentType.Maintained));

            var builder = new BenchmarkCriteriaBuilderService();

            var criteria = builder.BuildFromSimpleComparisonCriteria(benchmarkSchool.HistoricalFinancialDataModels.Last(), true, true, true, true, 5);

            Assert.AreEqual((financeObj.NoPupils - CriteriaSearchConfig.QC_DEFAULT_CONSTANT_PUPIL_COUNT_TOPUP) * 0.85m, criteria.MinNoPupil);
            Assert.AreEqual((financeObj.NoPupils + CriteriaSearchConfig.QC_DEFAULT_CONSTANT_PUPIL_COUNT_TOPUP) * 1.15m, criteria.MaxNoPupil);
        }
        public void BuildShouldApplyPercentageMarginForNumberOfPupils()
        {
            dynamic model = new ExpandoObject();

            model.NumberOfPupils = 100;

            var financeDoc = new Microsoft.Azure.Documents.Document();

            financeDoc.SetPropertyValue("No Pupils", 100d);
            financeDoc.SetPropertyValue("Overall Phase", "Secondary");
            financeDoc.SetPropertyValue("UrbanRuralInner", "Urban and city");
            financeDoc.SetPropertyValue("% of pupils eligible for FSM", 100);
            financeDoc.SetPropertyValue("% of pupils with SEN Statement", 100);
            financeDoc.SetPropertyValue("% of pupils with EAL", 100);
            financeDoc.SetPropertyValue("LA", 831);

            var benchmarkSchool = new SchoolViewModel(model);

            benchmarkSchool.HistoricalSchoolFinancialDataModels = new List <SchoolFinancialDataModel>();
            benchmarkSchool.HistoricalSchoolFinancialDataModels.Add(new SchoolFinancialDataModel("123", "2014-2015", financeDoc, SchoolFinancialType.Maintained));

            var builder = new BenchmarkCriteriaBuilderService();

            var criteria = builder.BuildFromSimpleComparisonCriteria(benchmarkSchool.HistoricalSchoolFinancialDataModels.Last(), true, true, true, true, 5);

            Assert.AreEqual(financeDoc.GetPropertyValue <double>("No Pupils") * 0.85, criteria.MinNoPupil);
            Assert.AreEqual(financeDoc.GetPropertyValue <double>("No Pupils") * 1.15, criteria.MaxNoPupil);
        }
        public void BuildShouldNotApplyOptionalCriteriaIfNotIncluded()
        {
            dynamic model = new ExpandoObject();

            model.NumberOfPupils = 100;

            var financeDoc = new Microsoft.Azure.Documents.Document();

            financeDoc.SetPropertyValue("No Pupils", 100d);
            financeDoc.SetPropertyValue("Overall Phase", "Secondary");
            financeDoc.SetPropertyValue("UrbanRuralInner", "Urban and city");
            financeDoc.SetPropertyValue("% of pupils eligible for FSM", 100);
            financeDoc.SetPropertyValue("% of pupils with SEN Statement", 100);
            financeDoc.SetPropertyValue("% of pupils with EAL", 100);
            financeDoc.SetPropertyValue("LA", 831);

            var benchmarkSchool = new SchoolViewModel(model);

            benchmarkSchool.HistoricalSchoolFinancialDataModels = new List <SchoolFinancialDataModel>();
            benchmarkSchool.HistoricalSchoolFinancialDataModels.Add(new SchoolFinancialDataModel("123", "2014-2015", financeDoc, SchoolFinancialType.Maintained));

            var builder = new BenchmarkCriteriaBuilderService();

            var criteria = builder.BuildFromSimpleComparisonCriteria(benchmarkSchool.HistoricalSchoolFinancialDataModels.Last(), false, false, false, false, 10);

            Assert.AreEqual(null, criteria.MinPerFSM);
            Assert.AreEqual(null, criteria.MaxPerFSM);
            Assert.AreEqual(null, criteria.MinPerSEN);
            Assert.AreEqual(null, criteria.MaxPerSEN);
            Assert.AreEqual(null, criteria.MinPerEAL);
            Assert.AreEqual(null, criteria.MaxPerEAL);
            Assert.AreEqual(null, criteria.LocalAuthorityCode);
        }
Beispiel #26
0
        public ActionResult Editar(SchoolViewModel schoolViewModel)
        {
            if (User.Identity.IsAuthenticated)
            {
                if (Int32.Parse(User.Identity.Name.Split(',')[1]) == 1)
                {
                    int userID = Int32.Parse(User.Identity.Name.Split(',')[0]);

                    List <School> schools = (from school in db.Schools where school.SchoolSequenceNumber == schoolViewModel.School.SchoolSequenceNumber && school.DeletionDate == null select school).ToList();

                    School currentSchool = db.Schools.Find(schoolViewModel.School.SchoolID);

                    if (schools.Count == 1 && schools.First().SchoolID != currentSchool.SchoolID)
                    {
                        ModelState.AddModelError("", Resources.WebResources.School_SchoolSequenceNumber_Unique);
                    }

                    if (ModelState.IsValid)
                    {
                        schoolViewModel.School.UpdateUser = Int32.Parse(User.Identity.Name.Split(',')[0]);
                        schoolViewModel.School.UpdateDate = DateTime.Now;

                        db.Entry(currentSchool).CurrentValues.SetValues(schoolViewModel.School);
                        db.SaveChanges();

                        return(View("_Hack"));
                    }

                    return(Content(GetErrorsFromModelState(schoolViewModel)));
                }
            }
            return(RedirectToAction("AccesoDenegado", "Home"));
        }
        private bool IsAreaFieldsValid(ComparisonArea?areaType, int?lacode, SchoolViewModel benchmarkSchool)
        {
            switch (areaType)
            {
            case ComparisonArea.LaCode:
                if (lacode == null)
                {
                    benchmarkSchool.ErrorMessage = "Please enter a valid Local authority code";
                }
                break;

            case ComparisonArea.LaName:
                if (lacode == null)
                {
                    benchmarkSchool.ErrorMessage = "Please select a local authority from the auto-completed list";
                }
                break;

            case null:
                benchmarkSchool.ErrorMessage = "Please select an area";
                break;
            }

            return(!benchmarkSchool.HasError());
        }
Beispiel #28
0
        public ActionResult VerNota(int id = 0)
        {
            if (User.Identity.IsAuthenticated)
            {
                if (Int32.Parse(User.Identity.Name.Split(',')[1]) <= 3 && Boolean.Parse(User.Identity.Name.Split(',')[2]))
                {
                    SchoolNote schoolNote = db.SchoolNotes.Find(id);
                    schoolNote.NoteType = db.NoteTypes.Find(schoolNote.NoteTypeID);
                    schoolNote.School   = db.Schools.Find(schoolNote.SchoolID);

                    SchoolViewModel schoolViewModel = new SchoolViewModel
                    {
                        Note = schoolNote
                    };

                    if (schoolViewModel.Note == null)
                    {
                        return(HttpNotFound());
                    }

                    return(PartialView("VerNota", schoolViewModel));
                }
            }

            return(RedirectToAction("AccesoDenegado", "Home"));
        }
        public async Task <IActionResult> Post([FromBody] SchoolViewModel school)
        {
            try
            {
                // Save to the Database
                _logger.LogInformation("Creating a new school");

                var newSchool = Mapper.Map <School>(school);

                //newSchool.UserName = User.Identity.Name;

                _repository.AddSchool(newSchool);

                if (await _repository.SaveChangesAsync())
                {
                    return(Created($"api/schools/{school.id}", Mapper.Map <SchoolViewModel>(school)));
                }
                else
                {
                    _logger.LogWarning("Could not save school to the database");
                }
            }
            catch (Exception ex)
            {
                _logger.LogError($"Threw exception while saving school: {ex}");
            }

            return(BadRequest("Failed to save the school"));
        }
Beispiel #30
0
        //
        // GET: /Escuelas/Details/5

        /// <summary>
        /// This method is responsible for searching for the particular Notes associated with a particular school,
        /// by means of using its specific id (the parameter recevied by the method).
        /// </summary>
        ///
        /// <param name="id">
        /// A unique integer that identifies each individual school.
        /// </param>
        ///
        /// <returns>
        /// Returns a schoolViewModel
        /// </returns>

        public ActionResult Detalles(int id = 0)
        {
            List <SchoolNote> schoolNotes = new List <SchoolNote>();

            if (Request.IsAuthenticated)
            {
                int currentUser = Int32.Parse(User.Identity.Name.Split(',')[0]);


                if (Int32.Parse(User.Identity.Name.Split(',')[1]) <= 2)
                {
                    schoolNotes = (from note in db.SchoolNotes.Include(note => note.NoteType) where note.SchoolID == id && note.DeletionDate == null orderby note.CreateDate descending select note).ToList();
                }
                else
                {
                    schoolNotes = (from note in db.SchoolNotes.Include(note => note.NoteType) where note.SchoolID == id && note.UserID == currentUser && note.DeletionDate == null orderby note.CreateDate descending select note).ToList();
                }
            }

            SchoolViewModel schoolViewModel = new SchoolViewModel
            {
                School = db.Schools.Find(id),
                Notes  = schoolNotes
            };

            if (schoolViewModel.School == null)
            {
                return(HttpNotFound());
            }

            return(View(schoolViewModel));
        }
        public IActionResult insertSchool(SchoolViewModel s)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToAction("adminPanel"));
            }

            Skola skola = new()
            {
                naziv = s.naziv,
                logo  = "no-image.jpg"
            };

            var file = s.logo;

            if (file != null)
            {
                skola.logo = s.naziv + "-Original-" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".png";
                var filePath = Directory.GetCurrentDirectory() + "/wwwroot/images/Skole";
                if (!Directory.Exists(filePath))
                {
                    Directory.CreateDirectory(filePath);
                }

                var        path = Path.Combine(filePath, skola.logo);
                FileStream fs   = new FileStream(path, FileMode.Create);
                file.CopyTo(fs);
                fs.Close();
            }

            _schoolServices.Insert(skola);
            return(RedirectToAction("adminPanel"));
        }
Beispiel #32
0
        // GET: School
        public virtual ActionResult Info(string name)
        {

            if (name.IsNullOrWhiteSpace())
            {
                return RedirectToAction("Index", "Home");
            }

            var school = _ctx.Campuses.First(c => c.Name == name);
            var model = new SchoolViewModel
            {
                Name = school.Name
            };

            return View(model);
        }
        public App()
        {
            ViewModel = new SchoolViewModel(Properties);

            MainPage = new NavigationPage(new StudentNotesHomePage());
        }