Пример #1
0
 public string createGenre(GenreEntity genreEntity)
 {
     using (var scope = new TransactionScope())
     {
         if (genreEntity != null)
         {
             if (!_uow.GenreRepository.Exists(genreEntity.genreStyle))
             {
                 var genre = GenreMapperInitializer(genreEntity);
                 _uow.GenreRepository.Insert(genre);
                 if (genreEntity.GenreMovies != null)
                 {
                     var genreMovies = GenreMovieMapperInitializer(genreEntity);
                     _uow.GenreMovieRepository.InsertBatch(genreMovies);
                 }
                 _uow.Commit();
                 scope.Complete();
                 return(genre.genreStyle);
             }
             else
             {
                 return("genres exist");
             }
         }
         return("-1");
     }
 }
Пример #2
0
        public ActionResult Create([Bind(Include = "Id,Name,Status,DateCreated,DateUpdated")] Organization organization)
        {
            if (ModelState.IsValid)
            {
                uow.OrgRepo.Add(organization);
                uow.Commit();
                return(RedirectToAction("Index"));
            }

            return(View(organization));
        }
        public ActionResult Edit([Bind(Prefix = "Testimonial")] Testimonial testimonial, [Bind(Include = "ImageSets")] List <Guid> imageSets)
        {
            Testimonial dbTestimonial = UOW.Testimonials.GetById(testimonial.TestimonialId);

            if (dbTestimonial != null)
            {
                dbTestimonial.Title       = testimonial.Title;
                dbTestimonial.Description = testimonial.Description;
                dbTestimonial.IsFeatured  = testimonial.IsFeatured;
                dbTestimonial.IsActive    = testimonial.IsActive;
                dbTestimonial.AccountId   = testimonial.AccountId;

                dbTestimonial.ImageSets.Clear();
                if (imageSets != null)
                {
                    dbTestimonial.ImageSets = UOW.ImageSets.GetSetByIds(imageSets);
                }

                UOW.Commit();
                testimonial = dbTestimonial;
            }
            else
            {
                return(HttpNotFound());
            }

            TestimonialVM vm = new TestimonialVM
            {
                Testimonial = testimonial,
                Accounts    = UOW.Accounts.GetAll(),
                ImageSets   = UOW.ImageSets.GetAll()
            };

            return(View(vm));
        }
Пример #4
0
        public ActionResult Create([Bind(Prefix = "Account")] Account account, [Bind(Include = "Users")] List <Guid> users)
        {
            if (ModelState.IsValid)
            {
                Account newAccount = new Account();
                newAccount.Id              = Guid.NewGuid();
                newAccount.Name            = account.Name;
                newAccount.ClientSinceDate = account.ClientSinceDate;
                newAccount.CreatedDate     = DateTime.Now;
                newAccount.IndustryType    = account.IndustryType;
                newAccount.IsActive        = account.IsActive;


                Counter dbCounter  = UOW.Counters.GetByName("Account_Number");
                int     nextNumber = dbCounter.CurrentNumber = dbCounter.CurrentNumber + 1;

                newAccount.Number = nextNumber.ToString();

                if (users != null)
                {
                    newAccount.SkyberryUsers = UOW.SkyberryUsers.GetSetByIds(users);
                }

                UOW.Accounts.Add(newAccount);
                UOW.Commit();
                account = newAccount;
            }
            AccountVM vm = new AccountVM
            {
                Account = account,
                Users   = UOW.SkyberryUsers.GetAll()
            };

            return(View("Edit", vm));
        }
Пример #5
0
        public ActionResult Edit([Bind(Prefix = "Account")] Account account, [Bind(Include = "Users")] List <Guid> users)
        {
            if (ModelState.IsValid)
            {
                Account dbAccount = UOW.Accounts.GetById(account.Id);
                if (dbAccount != null)
                {
                    dbAccount.Name            = account.Name;
                    dbAccount.ClientSinceDate = account.ClientSinceDate;
                    dbAccount.IndustryType    = account.IndustryType;
                    dbAccount.IsActive        = account.IsActive;

                    if (users != null)
                    {
                        dbAccount.SkyberryUsers = UOW.SkyberryUsers.GetSetByIds(users);
                    }

                    UOW.Commit();
                    account = dbAccount;
                }
                else
                {
                    return(HttpNotFound());
                }
            }
            AccountVM vm = new AccountVM
            {
                Account = account,
                Users   = UOW.SkyberryUsers.GetAll()
            };

            return(View(vm));
        }
Пример #6
0
        public ActionResult Edit([Bind(Prefix = "ImageSetItem")] ImageSetItem imageSetItem)
        {
            ImageSetItem dbImageSetItem = UOW.ImageSetItems.GetById(imageSetItem.ImageSetItemId);

            if (dbImageSetItem != null)
            {
                dbImageSetItem.ImageSetId = imageSetItem.ImageSetId;
                dbImageSetItem.ImageId    = imageSetItem.ImageId;
                dbImageSetItem.Position   = imageSetItem.Position;

                UOW.Commit();
                imageSetItem = dbImageSetItem;
            }
            else
            {
                return(HttpNotFound());
            }
            ImageSetItemVM vm = new ImageSetItemVM
            {
                ImageSetItem = imageSetItem,
                ImageSets    = UOW.ImageSets.GetAll(),
                Images       = UOW.Images.GetAll()
            };

            return(View(vm));
        }
Пример #7
0
        public ActionResult Edit([Bind(Prefix = "ReviewDocument")] ReviewDocument model)
        {
            ReviewDocument dbReviewDocument = UOW.ReviewDocuments.GetById(model.Id);

            if (dbReviewDocument != null)
            {
                dbReviewDocument.Title       = model.Title;
                dbReviewDocument.Order       = model.Order;
                dbReviewDocument.Description = model.Description;
                dbReviewDocument.Version     = model.Version;
                dbReviewDocument.DocType     = model.DocType;
                dbReviewDocument.IsActive    = model.IsActive;

                UOW.Commit();
                model = dbReviewDocument;
            }

            ReviewDocumentVM vm = new ReviewDocumentVM
            {
                ReviewDocument = model,
                DesignReviews  = UOW.DesignReviews.GetAll()
            };

            return(View(vm));
        }
        public ActionResult Create([Bind(Prefix = "Accolade")] Accolade accolade, [Bind(Include = "ImageSets")] List <Guid> imageSets)
        {
            if (ModelState.IsValid)
            {
                Accolade newAccolade = new Accolade();
                newAccolade.AccoladeId  = Guid.NewGuid();
                newAccolade.Title       = accolade.Title;
                newAccolade.Description = accolade.Description;
                newAccolade.IsActive    = accolade.IsActive;
                newAccolade.AccountId   = accolade.AccountId;

                newAccolade.ImageSets.Clear();
                if (imageSets != null)
                {
                    newAccolade.ImageSets = UOW.ImageSets.GetSetByIds(imageSets);
                }

                UOW.Accolades.Add(newAccolade);
                UOW.Commit();

                accolade = newAccolade;
            }

            AccoladeVM vm = new AccoladeVM
            {
                Accolade  = accolade,
                ImageSets = UOW.ImageSets.GetAll()
            };

            return(View("Edit", vm));
        }
Пример #9
0
        public IHttpActionResult ApproveProject(Guid rid)
        {
            DesignReview dbReview = UOW.DesignReviews.GetOwnById(rid, UserRecord.Id);

            if (dbReview == null)
            {
                return(new SkyApiNotFound(Request));
            }

            dbReview.ApprovedById   = UserRecord.Id;
            dbReview.ApprovedByName = UserRecord.FullName;
            dbReview.ApprovedByIp   = ""; // TODO djw: record requesting users IP address
            dbReview.ApprovedDate   = DateTime.UtcNow;

            UOW.Commit();

            IDictionary <string, string> formData = new Dictionary <string, string>();

            formData.Add("User", UserRecord.FullName);
            formData.Add("Project", dbReview.Project.Name);
            formData.Add("Review", dbReview.Title);
            MailService.SendNotification(formData, "Skyberry Notification: Project Approval");

            ReviewApprovedVM reviewApprovedVM = new ReviewApprovedVM
            {
                ApprovedById   = dbReview.ApprovedById,
                ApprovedByName = dbReview.ApprovedByName,
                ApprovedByIp   = dbReview.ApprovedByIp,
                ApprovedDate   = dbReview.ApprovedDate,
            };

            return(new SkyApiPayload <ReviewApprovedVM>(Request, reviewApprovedVM));
        }
Пример #10
0
        public ActionResult DeleteConfirmed(string id)
        {
            SkyberryUser user = UOW.SkyberryUsers.GetById(id);

            if (user == null)
            {
                return(HttpNotFound());
            }
            UserManager <SkyberryUser> UserManager = new UserManager <SkyberryUser>(new UserStore <SkyberryUser>(UOW.DbContext));

            if (user.UserName.ToLower() != "daniel" && user.UserName.ToLower() != "lacey")
            {
                var asyncCall = UserManager.RemoveFromRoleAsync(user.Id, "Client");
                if (asyncCall.Result.Succeeded)
                {
                    UOW.SkyberryUsers.Delete(user);
                    UOW.Commit();

                    return(RedirectToAction("Index"));
                }

                AddErrors(asyncCall.Result);
            }

            UserVM vm = new UserVM
            {
                User = user
            };

            return(View(vm));
        }
        public ActionResult Edit([Bind(Prefix = "Accolade")] Accolade accolade, [Bind(Include = "ImageSets")] List <Guid> imageSets)
        {
            Accolade dbAccolade = UOW.Accolades.GetById(accolade.AccoladeId);

            if (dbAccolade != null)
            {
                dbAccolade.Title       = accolade.Title;
                dbAccolade.Description = accolade.Description;
                dbAccolade.IsActive    = accolade.IsActive;
                dbAccolade.AccountId   = accolade.AccountId;

                dbAccolade.ImageSets.Clear();
                if (imageSets != null)
                {
                    dbAccolade.ImageSets = UOW.ImageSets.GetSetByIds(imageSets);
                }

                UOW.Commit();
                accolade = dbAccolade;
            }
            else
            {
                return(HttpNotFound());
            }

            AccoladeVM vm = new AccoladeVM
            {
                Accolade  = accolade,
                ImageSets = UOW.ImageSets.GetAll()
            };

            return(View(vm));
        }
        public ActionResult Create([Bind(Prefix = "Project")] Project project)
        {
            if (ModelState.IsValid)
            {
                Project newProject = new Project();
                newProject.Id                      = Guid.NewGuid();
                newProject.Name                    = project.Name;
                newProject.Description             = project.Description;
                newProject.Status                  = project.Status;
                newProject.StartDate               = project.StartDate;
                newProject.EstimatedCompletionDate = project.EstimatedCompletionDate;
                newProject.CompletionDate          = project.CompletionDate;
                newProject.CreatedDate             = DateTime.Now;
                newProject.AccountId               = project.AccountId;

                UOW.Projects.Add(newProject);
                UOW.Commit();
                project = newProject;
            }
            ProjectVM vm = new ProjectVM
            {
                Project  = project,
                Accounts = UOW.Accounts.GetAll()
            };

            return(View("Edit", vm));
        }
        public ActionResult Edit([Bind(Prefix = "Project")] Project project)
        {
            Project dbProject = UOW.Projects.GetById(project.Id);

            if (dbProject != null)
            {
                dbProject.Name                    = project.Name;
                dbProject.Description             = project.Description;
                dbProject.Status                  = project.Status;
                dbProject.StartDate               = project.StartDate;
                dbProject.EstimatedCompletionDate = project.EstimatedCompletionDate;
                dbProject.CompletionDate          = project.CompletionDate;
                dbProject.AccountId               = project.AccountId;

                UOW.Commit();
                project = dbProject;
            }

            ProjectVM vm = new ProjectVM
            {
                Project  = project,
                Accounts = UOW.Accounts.GetAll()
            };

            return(View(vm));
        }
        public ActionResult Create([Bind(Prefix = "Testimonial")] Testimonial testimonial, [Bind(Include = "ImageSets")] List <Guid> imageSets)
        {
            if (ModelState.IsValid)
            {
                Testimonial newTestimonial = new Testimonial();
                newTestimonial.TestimonialId = Guid.NewGuid();
                newTestimonial.Title         = testimonial.Title;
                newTestimonial.Description   = testimonial.Description;
                newTestimonial.IsFeatured    = testimonial.IsFeatured;
                newTestimonial.IsActive      = testimonial.IsActive;
                newTestimonial.AccountId     = testimonial.AccountId;

                newTestimonial.ImageSets.Clear();
                if (imageSets != null)
                {
                    newTestimonial.ImageSets = UOW.ImageSets.GetSetByIds(imageSets);
                }

                UOW.Testimonials.Add(newTestimonial);
                UOW.Commit();

                testimonial = newTestimonial;
            }

            TestimonialVM vm = new TestimonialVM
            {
                Testimonial = testimonial,
                Accounts    = UOW.Accounts.GetAll(),
                ImageSets   = UOW.ImageSets.GetAll()
            };

            return(View("Edit", vm));
        }
        public ActionResult Edit([Bind(Prefix = "DesignReview")] DesignReview designReview)
        {
            DesignReview dbDesignReview = UOW.DesignReviews.GetById(designReview.Id);

            if (dbDesignReview != null)
            {
                dbDesignReview.Title             = designReview.Title;
                dbDesignReview.Description       = designReview.Description;
                dbDesignReview.SelectedComment   = designReview.SelectedComment;
                dbDesignReview.AdditionalComment = designReview.AdditionalComment;
                dbDesignReview.AcceptedDate      = designReview.AcceptedDate;
                dbDesignReview.IsActive          = designReview.IsActive;
                dbDesignReview.ProjectId         = designReview.ProjectId;

                UOW.Commit();
                designReview = dbDesignReview;
            }

            DesignReviewVM vm = new DesignReviewVM
            {
                DesignReview = designReview,
                Projects     = UOW.Projects.GetAll()
            };

            return(View(vm));
        }
Пример #16
0
        public IHttpActionResult ClearOption(Guid rid)
        {
            DesignReview dbReview = UOW.DesignReviews.GetOwnById(rid, UserRecord.Id);

            if (dbReview == null)
            {
                return(new SkyApiNotFound(Request));
            }
            if (dbReview.AcceptedDate != null)
            {
                ModelState.AddModelError("", "Review has been accepted and further edits are not allowed.");
                return(new SkyApiBadRequest(Request, new SkyModelStateError(ModelState)));
            }

            // clear selected option
            dbReview.SelectedReviewDocumentId = null;
            // clear approval
            dbReview.ApprovedById   = null;
            dbReview.ApprovedByName = null;
            dbReview.ApprovedByIp   = null;
            dbReview.ApprovedDate   = null;
            // clear request
            dbReview.RequestById   = null;
            dbReview.RequestByName = null;
            dbReview.RequestByIp   = null;
            dbReview.RequestType   = RequestType.None;
            dbReview.RequestDate   = null;

            UOW.Commit();

            return(new SkyApiOkeydoke(Request));
        }
        public ActionResult Create([Bind(Prefix = "DesignReview")] DesignReview designReview)
        {
            if (ModelState.IsValid)
            {
                DesignReview newDesignReview = new DesignReview();
                newDesignReview.Id                = Guid.NewGuid();
                newDesignReview.Title             = designReview.Title;
                newDesignReview.Description       = designReview.Description;
                newDesignReview.SelectedComment   = designReview.SelectedComment;
                newDesignReview.AdditionalComment = designReview.AdditionalComment;
                newDesignReview.AcceptedDate      = designReview.AcceptedDate;
                newDesignReview.IsActive          = designReview.IsActive;
                newDesignReview.ProjectId         = designReview.ProjectId;

                UOW.DesignReviews.Add(newDesignReview);
                UOW.Commit();
                designReview = newDesignReview;
            }
            DesignReviewVM vm = new DesignReviewVM
            {
                DesignReview = designReview,
                Projects     = UOW.Projects.GetAll()
            };

            return(View("Edit", vm));
        }
Пример #18
0
        public ActionResult Create([Bind(Prefix = "Tag")] Tag tag, [Bind(Include = "Images")] List <Guid> images)
        {
            if (ModelState.IsValid)
            {
                Tag newTag = new Tag();
                newTag.TagId    = Guid.NewGuid();
                newTag.Name     = tag.Name;
                newTag.IsActive = tag.IsActive;
                newTag.IsFilter = tag.IsFilter;

                if (images != null)
                {
                    newTag.Images = UOW.Images.GetSetByIds(images);
                }

                UOW.Tags.Add(newTag);
                UOW.Commit();

                tag = newTag;
            }
            TagVM vm = new TagVM
            {
                Tag    = tag,
                Images = UOW.Images.GetAll()
            };

            return(View("Edit", vm));
        }
        public ActionResult Edit([Bind(Prefix = "Contract")] Contract contract, [Bind(Include = "Projects")] List <Guid> projects)
        {
            Contract dbContract = UOW.Contracts.GetById(contract.Id);

            if (dbContract != null)
            {
                dbContract.Title = contract.Title;

                dbContract.Projects.Clear();
                if (projects != null)
                {
                    dbContract.Projects = UOW.Projects.GetSetByIds(projects);

                    UOW.Commit();
                    contract = dbContract;
                }
                else
                {
                    ModelState.AddModelError(string.Empty, "Contracts must be associated with one or more projects.");
                }
            }
            else
            {
                return(HttpNotFound());
            }
            ContractVM vm = new ContractVM
            {
                Contract = contract,
                Projects = UOW.Projects.GetAll()
            };

            return(View(vm));
        }
Пример #20
0
        public ActionResult Create(NoteViewModel nvm)
        {
            var Note = new Note();

            Note = AutoMapper.Mapper.Map <NoteViewModel, Note>(nvm);
            if (ModelState.IsValid)
            {
                if (nvm.NoteType == NoteType.Contact)
                {
                    Note.ContactId = nvm.SrcId;
                }
                else
                {
                    Note.OrganizationId = nvm.SrcId;
                }
                Note.DateCreated     = DateTime.Now;
                Note.DateLastUpdated = DateTime.Now;
                Note.CreatedBy       = "biren";
                Note.UpdatedBy       = "biren";
                uow.NoteRepo.Add(Note);
                uow.Commit();

                if (nvm.NoteType == NoteType.Contact)
                {
                    return(RedirectToAction("Details", "Contacts", new { id = nvm.SrcId }));
                }
                else
                {
                    return(RedirectToAction("Details", "Organizations", new { id = nvm.SrcId }));
                }
            }

            return(View(nvm));
        }
Пример #21
0
        public ActionResult Edit([Bind(Prefix = "Tag")] Tag tag, [Bind(Include = "Images")] List <Guid> images)
        {
            Tag dbTag = UOW.Tags.GetById(tag.TagId);

            if (dbTag != null)
            {
                dbTag.Name     = tag.Name;
                dbTag.IsActive = tag.IsActive;
                dbTag.IsFilter = tag.IsFilter;

                dbTag.Images.Clear();
                if (images != null)
                {
                    dbTag.Images = UOW.Images.GetSetByIds(images);
                }

                UOW.Commit();
                tag = dbTag;
            }
            else
            {
                return(HttpNotFound());
            }

            TagVM vm = new TagVM
            {
                Tag    = tag,
                Images = UOW.Images.GetAll()
            };

            return(View(vm));
        }
Пример #22
0
        public virtual void Save(T t)
        {
            var agg = GetById(t.ID);

            agg.EnsureNotNull();

            var aggVersion = agg.Version;

            Monitor.Enter(_lockObj);

            using (UOW)
            {
                try
                {
                    //保存未执行的事件
                    foreach (var @event in agg.UnCommitEvents)
                    {
                        aggVersion++;
                        @event.Version = aggVersion;
                        EventService.SaveEvent(@event);
                    }

                    UOW.Commit();
                }
                catch
                {
                    UOW.RollBack();
                }
            }

            //发布消息,通知聚合根执行事件,并更改内存中的聚合根为最新状态
            EventService.Publish(agg.UnCommitEvents);

            Monitor.Exit(_lockObj);
        }
        public ActionResult Edit([Bind(Prefix = "Payment")] Payment payment)
        {
            Payment dbPayment = UOW.Payments.GetById(payment.Id);

            if (dbPayment != null)
            {
                dbPayment.Amount      = payment.Amount;
                dbPayment.PaymentType = payment.PaymentType;
                dbPayment.PaymentDate = payment.PaymentDate;
                dbPayment.AccountId   = payment.AccountId;

                UOW.Commit();
                payment = dbPayment;
            }
            else
            {
                return(HttpNotFound());
            }
            PaymentVM vm = new PaymentVM
            {
                Payment  = payment,
                Accounts = UOW.Accounts.GetAll()
            };

            return(View(vm));
        }
Пример #24
0
        public string createMovie(MovieEntity movieEntity)
        {
            using (var scope = new TransactionScope())
            {
                if (movieEntity != null)
                {
                    if (!_uow.MovieRepository.Exists(movieEntity.movie_name))
                    {
                        movie movieModel = MovieMapperInitializer(movieEntity);
                        ICollection <movieDirector> movieDirector = MovieDirectorMapperInitializer(movieEntity);
                        ICollection <movieGenre>    movieGenre    = MovieGenreMapperInitializer(movieEntity);
                        ;
                        _uow.MovieRepository.Insert(movieModel);

                        /*
                         * foreach(var dir in movieDirector)
                         * {
                         *  //如果导演不存在,则创建新的导演
                         *  if (!_uow.DirectoryRepository.Exists(dir.director))
                         *  {
                         *      _uow.DirectoryRepository.Insert(new director
                         *      {
                         *          director_name = dir.director
                         *      });
                         *
                         *      _uow.DirectorMovieRepository.Insert(new directorMovie
                         *      {
                         *          director_Id = dir.director
                         *      });
                         *  }
                         * }*/

                        _uow.MovieDirectorRepository.InsertBatch(movieDirector);
                        _uow.MovieGenreRepository.InsertBatch(movieGenre);

                        _uow.Commit();
                        scope.Complete();
                        return(movieModel.movie_name);
                    }
                    else
                    {
                        return("movie exist");
                    }
                }
                return("-1");
            }
        }
Пример #25
0
        public string createUser(UserEntity userEntity)
        {
            using (var scope = new TransactionScope())
            {
                if (userEntity != null)
                {
                    Mapper.Initialize(x => x.CreateMap <UserEntity, user>());
                    var user = Mapper.Map <UserEntity, user>(userEntity);


                    _uow.UserRepository.Insert(user);
                    _uow.Commit();
                    scope.Complete();
                    return(user.user_name);
                }
                return("-1");
            }
        }
Пример #26
0
        public ActionResult Create(ContactViewModel cvm)
        {
            var contact = new Contact();

            contact.FirstName   = cvm.FirstName;
            contact.LastName    = cvm.LastName;
            contact.EMail       = cvm.EMail;
            contact.PhoneNumber = cvm.PhoneNumber;
            contact.OrgID       = cvm.OrgId;
            if (ModelState.IsValid)
            {
                unitOfWork.ContactRepo.Add(contact);
                unitOfWork.Commit();
                return(RedirectToAction("Index"));
            }

            return(View(contact));
        }
Пример #27
0
        public ActionResult Create([Bind(Prefix = "Invoice")] Invoice invoice)
        {
            if (Request.Files.Count > 0 && Request.Files[0].ContentLength > 0)
            {
                if (ModelState.IsValid)
                {
                    HttpPostedFileBase file = Request.Files[0];

                    Guid   docId            = Guid.NewGuid();
                    string originalFilename = file.FileName;
                    string fileExt          = Path.GetExtension(file.FileName);
                    string filename         = docId.ToString() + fileExt;

                    string fullPath = StorageRoot + "\\" + filename;
                    file.SaveAs(fullPath);

                    Invoice newInvoice = new Invoice();
                    newInvoice.Id               = docId;
                    newInvoice.Filename         = filename;
                    newInvoice.FilenameOriginal = originalFilename;
                    newInvoice.FileExt          = fileExt;
                    newInvoice.FileMimeType     = GetMimeType(fullPath);
                    newInvoice.FileSize         = file.ContentLength;
                    newInvoice.FilePath         = "/files";
                    newInvoice.Title            = invoice.Title;
                    newInvoice.Amount           = invoice.Amount;
                    newInvoice.SentDate         = invoice.SentDate;
                    newInvoice.DueDate          = invoice.DueDate;
                    newInvoice.IsEstimate       = invoice.IsEstimate;
                    newInvoice.IsActive         = invoice.IsActive;
                    newInvoice.CreatedDate      = DateTime.Now;
                    newInvoice.AccountId        = invoice.AccountId;
                    newInvoice.ProjectId        = invoice.ProjectId;

                    Counter dbCounter  = UOW.Counters.GetByName("Invoice_InvoiceNumber");
                    int     nextNumber = dbCounter.CurrentNumber = dbCounter.CurrentNumber + 1;
                    newInvoice.InvoiceNumber = nextNumber.ToString();

                    UOW.Invoices.Add(newInvoice);
                    UOW.Commit();
                    invoice = newInvoice;
                }
            }
            else
            {
                ModelState.AddModelError(string.Empty, "You must supply a valid file.");
            }
            InvoiceVM vm = new InvoiceVM
            {
                Invoice  = invoice,
                Projects = UOW.Projects.GetAll(),
                Accounts = UOW.Accounts.GetAll()
            };

            return(View("Edit", vm));
        }
Пример #28
0
        public ActionResult Create([Bind(Prefix = "Image")] Image image, [Bind(Include = "Tags")] List <Guid> tags)
        {
            if (Request.Files.Count > 0 && Request.Files[0].ContentLength > 0)
            {
                HttpPostedFileBase file = Request.Files[0];

                Guid   docId            = Guid.NewGuid();
                string originalFilename = file.FileName;
                string fileExt          = Path.GetExtension(file.FileName);
                string filename         = docId.ToString() + fileExt;

                string fullPath = StorageRoot + "\\" + filename;
                file.SaveAs(fullPath);

                Image newImage = new Image();

                newImage.Id               = docId;
                newImage.Filename         = filename;
                newImage.FilenameOriginal = originalFilename;
                newImage.FileExt          = fileExt;
                newImage.FileMimeType     = GetMimeType(fullPath);
                newImage.FileSize         = file.ContentLength;
                newImage.Title            = image.Title;
                newImage.Description      = image.Description;
                newImage.Version          = image.Version;
                newImage.CreatedDate      = DateTime.Now;
                newImage.FilePath         = "/files";
                newImage.IsActive         = true;
                //newImage.ImageSetId = image.ImageSetId;

                if (tags != null)
                {
                    newImage.Tags = UOW.Tags.GetSetByIds(tags);
                }

                UOW.Images.Add(newImage);

                UOW.Commit();
                image = newImage;
            }
            else
            {
                ModelState.AddModelError(string.Empty, "You must supply a valid file.");
            }

            ImageVM vm = new ImageVM
            {
                Image = image,
                Tags  = UOW.Tags.GetAll(),
                //ImageSets = UOW.ImageSets.GetAll()
            };

            return(View("Edit", vm));
        }
Пример #29
0
        public ActionResult DeleteConfirmed(Guid id)
        {
            Tag tag = UOW.Tags.GetById(id);

            if (tag == null)
            {
                return(HttpNotFound());
            }
            UOW.Tags.Delete(tag);
            UOW.Commit();
            return(RedirectToAction("Index"));
        }
        public ActionResult DeleteConfirmed(Guid id)
        {
            ContractDocument contractDocument = UOW.ContractDocuments.GetById(id);

            if (contractDocument == null)
            {
                return(HttpNotFound());
            }
            UOW.ContractDocuments.Delete(contractDocument);
            UOW.Commit();
            return(RedirectToAction("Index"));
        }