public int Insert(Owner owner) { using (IDbConnection conn = _db.OpenDbConnection()) { conn.Insert(owner); return (int)conn.GetLastInsertId(); } }
public ActionResult CreateOwner(VMOwner model) { if (ModelState.IsValid) { if (model.OwnerId == 0) //create { var owner = new Owner { OwnerName = model.OwnerName, OwnerDirectory = model.OwnerDirectory, UserId = model.UserId }; var newOwnerId = GalleryService.InsertOwner(owner); model.OwnerId = newOwnerId; model.AddOKMessage("Nový vlastník galerie úspěšně přidán."); } } return View(model); }
public List<OrigPhotosWaiting> GetWaitingPhotos(Owner owner, string subDir) { var retColl = new List<OrigPhotosWaiting>(); var currentUserDir = HttpContext.Current.Server.MapPath(string.Format("{0}/{1}", _baseService.AppConfig.GalleryImagesRoot, owner.OwnerDirectory )); var uploadPath = string.Format(@"{0}\{1}", currentUserDir, _baseService.AppConfig.UploadDirName); if (!string.IsNullOrEmpty(subDir)) { uploadPath = string.Format(@"{0}\{1}", uploadPath, subDir); } var files = GetFilesInDirectory(uploadPath); if (files.Length > 0) { var uploadType = _photoRepo.GetBySystemName("upload"); var adminThumb = _photoRepo.GetBySystemName("adminthumb"); uploadType.Directory = uploadType.Directory + @"\" + subDir; for (int i = 0; i < files.Length; i++) { var photoAlreadyInDb = GetPhotoByFileName(files[i].Name); string fileName; int photoId; if (photoAlreadyInDb == null) //fotku sme jeste nezpracovavali { fileName = RenameToSystemFileName(files[i].FullName); var fotka = new Photo { FileName = fileName, OwnerId = owner.OwnerId, DateUploaded = files[i].CreationTime, DateCreated = DateTime.Now, PhotoTypes = new List<PhotoType>{uploadType}, Owner = owner, BasePhotoVirtualPath = _baseService.AppConfig.GalleryImagesRoot }; photoId = InsertPhoto(fotka); fotka.PhotoId = photoId; try { ImageProcessingService.ResizeImage(fotka, uploadType, adminThumb); AddPhotoTypeToPhoto(fotka, adminThumb); } catch (Exception) { throw; } } else { fileName = photoAlreadyInDb.FileName; photoId = photoAlreadyInDb.PhotoId; } var photoWaiting = new OrigPhotosWaiting { FileName = fileName, UploadedDate = files[i].CreationTime, PhotoId = photoId}; //X,Y dimensions of originally uploaded photo - uncomment if you need to diplay it on ProcessUploadPhotos view. //var origPath = HttpContext.Current.Server.MapPath(string.Format("/{0}/{1}/{2}/{3}", ConfigurationManager.AppSettings["GalleryRootDirVirtualPath"], currentUserDir, uploadType.Adresar, fileName)); //var origDimensions = ImageProcessingManager.GetImageDimensions(origPath); //photoWaiting.X = origDimensions[0]; //photoWaiting.Y = origDimensions[1]; photoWaiting.ThumbPath = string.Format("{0}/{1}/{2}/{3}", _baseService.AppConfig.GalleryImagesRoot, owner.OwnerDirectory, adminThumb.Directory, fileName); retColl.Add(photoWaiting); } } return retColl; }
public List<OrigPhotoSubDirectory> GetSubDirs(Owner owner, string subDir) { var currentUserDir = HttpContext.Current.Server.MapPath(string.Format("{0}/{1}", _baseService.AppConfig.GalleryImagesRoot, owner.OwnerDirectory)); var uploadPath = string.Format(@"{0}\{1}", currentUserDir, _baseService.AppConfig.UploadDirName); if (!string.IsNullOrEmpty(subDir)) { uploadPath = string.Format(@"{0}\{1}", uploadPath, subDir); } var dirInfo = new DirectoryInfo(uploadPath); var retColl = new List<OrigPhotoSubDirectory>(); var subDirs = dirInfo.GetDirectories(); var innerSubDir = string.IsNullOrEmpty(subDir) ? "" : subDir + @"\"; if (subDirs.Any()) { //only show directories that have files or subdirs in it. foreach (var subdir in subDirs) { var files = subdir.GetFiles(); var subdirs = subdir.GetDirectories(); if (files.Length > 0 || subdirs.Length > 0) { retColl.Add(new OrigPhotoSubDirectory { DirName = subdir.Name, FullParentPath = innerSubDir + subdir.Name }); } } } return retColl; }
public void UpdateOwner(Owner owner) { _baseService.UserRepo.Update(owner); _baseService.Cacher.RemoveAll(new List<string> { OWNERS_ALL, OWNER_ID.Fmt(owner.OwnerId) }); }
public int InsertOwner(Owner owner) { var newOwnerId = _baseService.UserRepo.Insert(owner); owner.OwnerId = newOwnerId; _baseService.Cacher.RemoveAll(new List<string> { OWNERS_ALL, OWNER_ID.Fmt(newOwnerId) }); return newOwnerId; }
public void Update(Owner owner) { using (IDbConnection conn = _db.OpenDbConnection()) { conn.Update(owner); } }
private void CreateTrashGallery(Owner owner) { var trashGal = new Gallery { DateCreated = DateTime.Now, Description = "Trash galerie uživatele {0}.".Fmt(owner.OwnerName), GalleryType = (int)GalleryTypes.Trash, Name = "Trash galerie uživatele {0}.".Fmt(owner.OwnerName), Order = 9999, OwnerId = owner.OwnerId, ParentId = null, Year = DateTime.Now.Year.ToString() }; _galleryRepo.InsertGallery(trashGal); }
public int InsertOwner(Owner owner) { var newOwnerId = UserService.InsertOwner(owner); _baseService.Cacher.RemoveAll(new List<string> { GALLERIES_ALL, GALLERIES_BY_OWNERID.Fmt(newOwnerId) }); EnsureOwnerSetup(newOwnerId); return newOwnerId; }