예제 #1
0
        public async Task <IActionResult> Create([Bind("Name,Order")] ProjectEntity project)
        {
            if (ModelState.IsValid)
            {
                project.CreateTime     = DateTime.Now;
                project.LastModifyTime = DateTime.Now;
                UserEntity usere = _context.Set <UserEntity>().SingleOrDefault(t => t.Account == HttpContext.User.Identity.Name);
                project.CreatorUserId    = usere.Id;
                project.LastModifyUserId = project.CreatorUserId;
                project.Id = Guid.NewGuid().ToString("N");
                _context.Add(project);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(project));
        }
예제 #2
0
        //[ValidateAntiForgeryToken]
        public async Task <IActionResult> Create(UserStoryViewModel userStoryViewModel)
        {
            if (ModelState.IsValid)
            {
                //mapping
                UserStoryEntity usNew = mapper.Map <UserStoryEntity>(userStoryViewModel);
                usNew.Id         = Guid.NewGuid().ToString("N");
                usNew.StatusCode = "Unstarted";
                UserEntity currentUser = _context.Set <UserEntity>().SingleOrDefault(t => t.Account == User.Identity.Name);
                usNew.CreatorUserId = currentUser.Id;
                usNew.CreateTime    = DateTime.Now;
                usNew.SortCode      = _context.UserStories.Max(t => t.SortCode) + 1;
                _context.UserStories.Add(usNew);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View("OK"));
        }