Ejemplo n.º 1
0
        public ActionResult GetChartsForPerson(int id)
        {
            try {
                var factory = new ChartFactory();
                var person  = _personHandler.Select(id);
                var times   = _timeHandler.GetTimesByPeople(new List <PersonDTO> {
                    person
                });
                var charts = factory.CreateChartDataModels_Person(times);

                return(Json(charts, JsonRequestBehavior.AllowGet));
            }
            catch (InvalidDataException e)
            {
                HttpContext.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
                return(Json(e.Message, JsonRequestBehavior.AllowGet));
            }
            catch (Exception e)
            {
                HttpContext.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
                return(Json("An unknown error occoured!", JsonRequestBehavior.AllowGet));
            }
        }
Ejemplo n.º 2
0
        protected override DbObjDTO GetDtoFromCollection(int id, FormCollection collection)
        {
            var permission = new PermissionDTO()
            {
                Pk   = id,
                FK_P = int.Parse(collection["FK_P"]),
                FK_U = int.Parse(collection["FK_U"])
            };

            var personHandler = new DbPersonHandler();
            var userHandler   = new DbUserHandler();

            permission.Person = personHandler.Select(permission.FK_P);
            permission.User   = userHandler.Select(permission.FK_U);

            return(permission);
        }
Ejemplo n.º 3
0
        public FileResult GetImportFile()
        {
            var disciplineId = Request.Params["discipline"];
            var discipline   = _disciplineHandler.Select(int.Parse(disciplineId));

            var peopleIdarr = Request.Params["people"].Split(',');

            var people = new List <PersonDTO>();

            for (var i = 0; i < peopleIdarr.Length; i++)
            {
                var personId = int.Parse(peopleIdarr[i]);
                var person   = _personHandler.Select(personId);
                people.Add(person);
            }

            var writer   = new ExcelWriter(discipline, people, new List <DateTime>());
            var filePath = writer.GetExcelFilePath();

            var fileBytes = System.IO.File.ReadAllBytes(filePath);
            var fileName  = "import.xls";

            return(File(fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet, fileName));
        }