Esempio n. 1
0
 public void NewTeam(ref Project project)
 {
     Id = Guid.NewGuid();
     Name = project.Name;
     Admin = project.Admin;
     Time = DateTime.Now;
     Introduction = "此处的信息将作为团队的对外介绍。";
     Announcement = "此处的信息将作为团队的内部公告";
     project.Team = this;
     using (BaseDbContext db = new BaseDbContext())
     {
         var TeamRecord = new TeamRecord(this, TeamMemberStatus.Admin,Extensions.GetContextUser(db));
     }
 }
        public ActionResult Project(Project model)
        {
            if (ModelState.IsValid)
            {
                User user = db.Users.Find(Extensions.GetUserId());
                if (Request.Files.Count != 1)//如果文件列表为空则返回
                    return View();
                var file = Request.Files[0];//只上传第一个文件
                if (!MaterialType.Avatar.Match(file))
                {
                    TempData["Alert"] = "请上传格式为jpg, jpeg,png的图片";
                    model.Avatar = null;
                    var data = db.IndustryLists.OrderBy(i => i.IndustryName).ToList();
                    if (data.Count() == 0)
                    {
                        data.Add(new IndustryList { ID = Guid.Empty, IndustryName = "空" });
                    }
                    ViewBag.Industry = new SelectList(data, "IndustryName", "IndustryName");
                    ViewData["ProgressList"] = EnumExtension.GetSelectList(typeof(ProjectProgressType));
                    return View(model);
                }
                if (model.Avatar == null)
                {
                    model.Avatar = Material.Create("", MaterialType.Avatar, file, db);
                }
                else
                {
                    model.Avatar = Material.ChangeFile(model.Avatar.Id, file, db);
                }
                Project old = Extensions.GetContextUser(ref db).Project;
                if (old != null)
                {
                    db.Entry(db.Projects.Find(old.Id)).State = System.Data.Entity.EntityState.Deleted;
                    db.SaveChanges();
                }
                model.NewProject(db);
                db.Projects.Add(model);
                user.Project = model;
                db.SaveChanges();

                return RedirectToAction("Index", new { Message = ManageMessageId.ProjectSuccess });
            }

            return RedirectToAction("Index", new { Message = ManageMessageId.Error });
        }
 public void NewTeam(ref Project project)
 {
     Id = Guid.NewGuid();
     Name = project.Name;
     Admin = project.Admin;
     Time = DateTime.Now;
     Introduction = "此处的信息将作为团队的对外介绍。";
     Announcement = "此处的信息将作为团队的内部公告";
     Searchable = true;
     ReportUpdated = false;
     project.Team = this;
     var db = new BaseDbContext();
     var TeamRecord = new TeamRecord(this, TeamMemberStatus.Admin, Extensions.GetContextUser(ref db));
 }
 public ProjectListVM CreateProjectListVM(Project item)
 {
     return new ProjectListVM
     {
         Id = item.Id,
         Name = item.Name,
         Slug = SlugUtils.ToSlug(item.Name),
         Status = item.Status,
     };
 }
        public ProjectVM CreateProjectVM(Project item)
        {
            return new ProjectVM
            {
                Id = item.Id,
                Name = item.Name,
                Slug = SlugUtils.ToSlug(item.Name),
                Description = item.Description,
                Status = item.Status,
                StartDate = item.StartDate,
                EstimatedCompletionDate = item.EstimatedCompletionDate,
                CompletionDate = item.CompletionDate,
                AccountId = item.AccountId,

                Contracts = item.Contracts.OrderByDescending(e => e.CreatedDate).Select(e => this.CreateContractVM(e)).ToList(),
                Reviews = item.DesignReviews.OrderByDescending(e => e.CreatedDate).ThenByDescending(e => e.Title).Select(e => this.CreateDesignReviewVM(e)).ToList(),
                Docs = item.ProjectDocuments.OrderByDescending(e => e.CreatedDate).Select(e => this.CreateProjectDocumentVM(e)).ToList(),
            };
        }
Esempio n. 6
0
        public ActionResult Project(Project model)
        {
            if (ModelState.IsValid)
            {
                if (Request.Files.Count != 1)//如果文件列表为空则返回
                    return View();
                var file = Request.Files[0];//只上传第一个文件

                if (model.Avatar == null)
                {
                    model.Avatar = Material.Create("", MaterialType.Avatar, file, db);
                }
                else
                {
                    model.Avatar = Material.ChangeFile(model.Avatar.Id, file, db);
                }
                if (Extensions.GetContextUser(db).Project != null)
                    db.Entry(model).State = System.Data.Entity.EntityState.Modified;
                else
                {
                    model.NewProject(db);
                    db.Projects.Add(model);
                    db.SaveChanges();
                }
                db.SaveChanges();

                return RedirectToAction("Index", new { Message = ManageMessageId.ProjectSuccess });
            }

            return RedirectToAction("Index", new { Message = ManageMessageId.Error });
        }