Esempio n. 1
0
        public IActionResult DeleteFile(string fileName)
        {
            ViewBag.response = responseFromDeleteFileAPI(fileName).responseType;
            UserResponse        actualUser        = HttpContext.Session.getObjectFromJson <UserResponse>("actualUser");
            List <ProjectModel> operations        = responseFromOperationAPI(actualUser.id);
            List <ProjectModel> runningOperations = new List <ProjectModel>();
            List <ProjectModel> historyOperations = new List <ProjectModel>();

            foreach (ProjectModel p in operations)
            {
                if (!isFinalizedOperation(p))
                {
                    runningOperations.Add(p);
                }
                else
                {
                    historyOperations.Add(p);
                }
            }
            ViewBag.runningOperations = runningOperations;
            ViewBag.historyOperations = historyOperations;
            ViewBag.allOperations     = OperationDAL.getAll();
            ViewBag.isLogged          = true;
            return(View("Index"));
        }
Esempio n. 2
0
        public IActionResult Index()
        {
            UserResponse        actualUser        = HttpContext.Session.getObjectFromJson <UserResponse>("actualUser");
            List <ProjectModel> operations        = responseFromOperationAPI(actualUser.id);
            List <ProjectModel> runningOperations = new List <ProjectModel>();
            List <ProjectModel> historyOperations = new List <ProjectModel>();

            foreach (ProjectModel p in operations)
            {
                if (!isFinalizedOperation(p))
                {
                    runningOperations.Add(p);
                }
                else
                {
                    historyOperations.Add(p);
                }
            }
            ViewBag.runningOperations = runningOperations;
            ViewBag.historyOperations = historyOperations;
            ViewBag.allOperations     = OperationDAL.getAll();
            return(View());
        }
Esempio n. 3
0
        public IActionResult Index(UserModel usuario)
        {
            int estadoUsuario = 0, estadoContraseña = 0; string antiguoUsuario = "";

            if (!isEmpty(usuario.email))
            {
                if (!isEmpty(usuario.password))
                {
                    usuario.typeAccess = 2;//2 for Employees
                    UserResponse response = responseFromLoginAPI(usuario);
                    if (response.responseType == 3)
                    {
                        //All OK
                        usuario.typeAccess = Convert.ToInt32(response.email);
                        HttpContext.Session.setObjectAsJson("actualUser", usuario);
                        List <ProjectModel> operations        = responseFromOperationAPI(response.id);
                        List <ProjectModel> runningOperations = new List <ProjectModel>();
                        List <ProjectModel> historyOperations = new List <ProjectModel>();
                        foreach (ProjectModel p in operations)
                        {
                            if (!isFinalizedOperation(p))
                            {
                                runningOperations.Add(p);
                            }
                            else
                            {
                                historyOperations.Add(p);
                            }
                        }
                        //This is for some operation's Timeline
                        ViewBag.runningOperations = runningOperations;
                        ViewBag.historyOperations = historyOperations;
                        ViewBag.allOperations     = OperationDAL.getAll();
                        ViewBag.isLogged          = true;
                        return(View());
                    }
                    else if (response.responseType == 2)
                    {
                        //CONTRASEÑA INCORRECTA
                        estadoContraseña = 1;
                        antiguoUsuario   = usuario.email;
                    }
                    else
                    {
                        //USUARIO NO EXISTE
                        estadoUsuario  = 1;
                        antiguoUsuario = usuario.email;
                    }
                }
                else
                {
                    //CONTRASEÑA NO INTRODUCIDA
                    estadoContraseña = 2;
                    antiguoUsuario   = usuario.email;
                }
            }
            else
            {
                //USUARIO NO INTRODUCIDO
                estadoUsuario = 2;
            }
            return(RedirectToAction("Login", "Home", new
            {
                estadoUsuario,
                estadoContraseña,
                antiguoUsuario
            }));
        }
Esempio n. 4
0
        public IActionResult UploadFile(string fileIds, IFormFile file)
        {
            string stringFile = "";

            string[] elements   = file.FileName.Split(".");
            string   formatFile = elements[elements.Length - 1];
            int      response   = 0;

            string[] datos     = fileIds.Split("#");
            string[] names     = datos[0].Split("*");
            string[] ids       = datos[1].Split("_");
            int      projectId = Convert.ToInt32(ids[2]);
            int      taskId    = Convert.ToInt32(ids[0]);

            if (file != null)
            {
                if (file.Length < getMegaBytes(5))
                {
                    using (var ms = new MemoryStream())
                    {
                        file.CopyTo(ms);
                        var fileBytes = ms.ToArray();
                        stringFile = Convert.ToBase64String(fileBytes);
                    }
                    string    taskFileName = $"{names[0]}-{names[1]}({projectId}{taskId}).{formatFile}";
                    FileModel newFileModel = new FileModel
                    {
                        idTask          = taskId,
                        idProject       = projectId,
                        documentContent = stringFile,
                        documentName    = taskFileName,
                        format          = formatFile
                    };
                    response = resonseFromUploadFileAPI(newFileModel).responseType;
                }
                else
                {
                    response = 3;
                }
            }
            ViewBag.response = response;
            UserResponse        actualUser        = HttpContext.Session.getObjectFromJson <UserResponse>("actualUser");
            List <ProjectModel> operations        = responseFromOperationAPI(actualUser.id);
            List <ProjectModel> runningOperations = new List <ProjectModel>();
            List <ProjectModel> historyOperations = new List <ProjectModel>();

            foreach (ProjectModel p in operations)
            {
                if (!isFinalizedOperation(p))
                {
                    runningOperations.Add(p);
                }
                else
                {
                    historyOperations.Add(p);
                }
            }
            ViewBag.runningOperations = runningOperations;
            ViewBag.historyOperations = historyOperations;
            ViewBag.allOperations     = OperationDAL.getAll();
            ViewBag.isLogged          = true;
            return(View("Index"));
        }