예제 #1
0
        /// <summary>
        /// The get save image routine.
        /// </summary>
        /// <param name="subModuleItem">
        /// The sub module item.
        /// </param>
        /// <param name="creator">
        /// The creator.
        /// </param>
        /// <returns>
        /// The save image routine
        /// </returns>
        private Func <string, string, File> GetSaveImageRutine(SubModuleItem subModuleItem, User creator)
        {
            Func <string, string, File> saveImage = (imageName, imageData) =>
            {
                if (string.IsNullOrEmpty(imageName) || string.IsNullOrEmpty(imageData))
                {
                    return(null);
                }

                FileModel fileModel = this.FileModel;
                File      file      = fileModel.CreateFile(
                    subModuleItem.Return(x => x.CreatedBy, creator),
                    imageName,
                    default(DateTime),
                    null,
                    null,
                    null,
                    null);
                byte[] byteData = System.Convert.FromBase64String(imageData);
                fileModel.SetData(file, byteData);

                string permanentFileName = fileModel.PermanentFileName(file);
                using (FileStream stream = System.IO.File.OpenWrite(permanentFileName))
                {
                    fileModel.ResizeImage(byteData, fileModel.PermanentFileName(file), stream);
                }

                return(file);
            };

            return(saveImage);
        }
예제 #2
0
        public ActionResult Login(FormCollection collection)
        {
            var User   = collection["User"];
            var search = Storage.Instance.Users.Where(x => x.User == User).ToList();

            if (search.Count != 0)
            {
                foreach (var item in search)
                {
                    if (collection["User"] == item.User && collection["Password"] == item.Password)
                    {
                        if (item.Job == "Developer")
                        {
                            Storage.Instance.UserLogin = item;
                            if (Storage.Instance.route == null)
                            {
                                Storage.Instance.route = Server.MapPath("~/Helpers/Disck.txt");
                                FileModel.CreateFile();
                            }
                            else
                            {
                                FileModel.ReadFiles();
                            }
                            return(RedirectToAction("CreateWork", "Work"));
                        }
                    }
                    else
                    {
                        Storage.Instance.UserLogin = item;
                        if (Storage.Instance.route == null)
                        {
                            Storage.Instance.route = Server.MapPath("~/Helpers/Disck.txt");
                            FileModel.CreateFile();
                        }
                        else
                        {
                            FileModel.ReadFiles("ProjectManager");
                        }
                        Storage.Instance.UserLogin = item;
                        return(View("ProjectManager"));
                    }
                }
                ViewBag.UserDontSerched = "Usuario y contraseña no coinsiden";
                return(View());
            }
            else
            {
                ViewBag.UserDontSerched = "Usuario no existente";
                return(View());
            }
        }