Exemplo n.º 1
0
        public IActionResult Create(User item)
        {
            _context.Users.Add(item);
            _context.SaveChanges();

            return(CreatedAtRoute("GetUser", new { id = item.Id }, item));
        }
Exemplo n.º 2
0
        public IActionResult Create(Bug item)
        {
            _context.Bugs.Add(item);
            _context.SaveChanges();

            return(CreatedAtRoute("GetBug", new { id = item.Id }, item));
        }
Exemplo n.º 3
0
        public ActionResult Create([Bind(Include = "Id,Status,Text,DateCreated")] Bug bug)
        {
            if (ModelState.IsValid)
            {
                db.Bugs.Add(bug);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(bug));
        }
Exemplo n.º 4
0
 public (bool, string) CreateWorkItem(WorkItems item)
 {
     try
     {
         db.WorkItem.Add(item);
         db.SaveChanges();
         return(true, "Workitem created successfully");
     }
     catch (Exception ex)
     {
         return(false, ex.Message);
     }
 }
        public void Initialize(BugTrackerContext context)
        {
            if (!context.ProjectItems.Any())
            {
                context.Add(new ProjectItem {
                    Name = "Task 1", Description = "Task 1", Created = DateTime.UtcNow.AddDays(1), Modified = DateTime.UtcNow.AddDays(1)
                });
                context.Add(new ProjectItem {
                    Name = "Task 2", Description = "Task 2", Created = DateTime.UtcNow.AddDays(-1), Modified = DateTime.UtcNow.AddDays(-1)
                });
                context.Add(new ProjectItem {
                    Name = "Task 3", Description = "Task 3", Created = DateTime.UtcNow.AddDays(2), Modified = DateTime.UtcNow.AddDays(2)
                });
            }

            if (!context.TaskItems.Any())
            {
                context.Add(new TaskItem {
                    Name = "Task 1", Description = "Task 1", Priority = TaskItem.TaskPriority.High, Created = DateTime.Now.AddDays(1), Modified = DateTime.UtcNow.AddDays(1)
                });
                context.Add(new TaskItem {
                    Name = "Task 2", Description = "Task 2", Priority = TaskItem.TaskPriority.Low, Created = DateTime.Now.AddDays(-1), Modified = DateTime.UtcNow.AddDays(-1)
                });
                context.Add(new TaskItem {
                    Name = "Task 3", Description = "Task 3", Priority = TaskItem.TaskPriority.Medium, Created = DateTime.Now.AddDays(2), Modified = DateTime.UtcNow.AddDays(2)
                });
            }

            context.SaveChanges();
        }
Exemplo n.º 6
0
        public ActionResult Create([FromBody] JObject input)
        {
            Issue newIssue = input.ToObject <Issue>();

            _db.Issues.Add(newIssue);
            _db.SaveChanges();
            return(RedirectToAction("IssueIndex"));
        }
Exemplo n.º 7
0
        public void Log(IUseCase useCase, IApplicationActor applicationActor, object useCaseData)
        {
            _context.UseCaseLogs.Add(new Domain.UseCaseLog
            {
                Actor       = applicationActor.Identity,
                Data        = JsonConvert.SerializeObject(useCaseData),
                Date        = DateTime.Now,
                UseCaseName = useCase.Name
            });

            _context.SaveChanges();
        }
Exemplo n.º 8
0
        public BugController(BugTrackerContext context)
        {
            _context = context;

            _context.Bugs.Include(b => b.AssignedToUser);

            if (_context.Bugs.Count() == 0)
            {
                // Create test data here. TODO: Wire up to db later.
                _context.Users.Add(new User {
                    Id = 1, Name = "James Radley"
                });
                _context.Users.Add(new User {
                    Id = 2, Name = "Jane Doe"
                });
                _context.Users.Add(new User {
                    Id = 3, Name = "Joe Bloggs"
                });
                _context.SaveChanges();
            }

            if (_context.Bugs.Count() == 0)
            {
                // Create test data here. TODO: Wire up to db later.
                _context.Bugs.Add(new Bug {
                    Id = 1, Title = "A bug", Description = "This is a bug", DateOpened = new DateTime(2018, 03, 01), IsActive = true, AssignedToUserId = 1
                });
                _context.Bugs.Add(new Bug {
                    Id = 2, Title = "Another bug", Description = "Here is another bug", DateOpened = new DateTime(2018, 05, 14), IsActive = true, AssignedToUserId = 1
                });
                _context.Bugs.Add(new Bug {
                    Id = 3, Title = "Yet Another bug", Description = "Here is yet another bug", DateOpened = new DateTime(2018, 06, 01), IsActive = true, AssignedToUserId = 2
                });
                _context.Bugs.Add(new Bug {
                    Id = 4, Title = "And Finally Another bug", Description = "Here is finally another bug", DateOpened = new DateTime(2018, 08, 17), IsActive = true, AssignedToUserId = 3
                });
                _context.SaveChanges();
            }
        }
Exemplo n.º 9
0
 static void Main(string[] args)
 {
     using (var c = new BugTrackerContext())
     {
         c.Database.Delete();
         c.Database.Create();
     }
     using (var c = new BugTrackerContext())
     {
         var user = c.Users.Create();
         user.Login     = "******";
         user.FirstName = "Giovanni";
         user.LastName  = "Solinas";
         user.Password  = "******";
         user.BirthDate = new DateTime(1998, 9, 11);
         user.Address   = new Address()
         {
             ZipCode = 16100
         };
         c.Users.Add(user);
         c.SaveChanges();
     }
     using (var c = new BugTrackerContext())
     {
         var product = c.Products.Create();
         product.Code           = 42;
         product.CommercialName = "Motore";
         product.InternalName   = "Motore 1.5 95 cv";
         product.Description    = "abajdcowjdbcjdbcwjbcw";
         c.Products.Add(product);
         c.SaveChanges();
     }
     using (var c = new BugTrackerContext())
     {
         var product = c.Products.Create();
         product.Code           = 27;
         product.CommercialName = "Matita";
         product.InternalName   = "Matita bianca";
         product.Description    = "oojosjcbdwjcoswcojbwe";
         c.Products.Add(product);
         c.SaveChanges();
     }
     using (var c = new BugTrackerContext())
     {
         var product1 = c.Products.FirstOrDefault(p => p.Code == 1);
         var product2 = c.Products.FirstOrDefault(p => p.Code == 2);
         product1.DependsOn.Add(product2);
         c.SaveChanges();
     }
 }
Exemplo n.º 10
0
        public UserController(BugTrackerContext context)
        {
            _context = context;

            if (_context.Users.Count() == 0)
            {
                // Create test data here. TODO: Wire up to db later.
                _context.Users.Add(new User {
                    Id = 1, Name = "James Radley"
                });
                _context.Users.Add(new User {
                    Id = 2, Name = "Jane Doe"
                });
                _context.Users.Add(new User {
                    Id = 3, Name = "Joe Bloggs"
                });
                _context.SaveChanges();
            }
        }
Exemplo n.º 11
0
        public ActionResult Create(IssueCreateModel model)
        {
            var today = DateTime.Today;

            var newIssue = new Issue
            {
                Title       = model.Title,
                Description = model.Description,
                BeginDate   = today,
                EndDate     = today.AddDays(5),
                Price       = (decimal)model.Price,
                Status      = IssueStatuses.New
            };

            context.Issues.Add(newIssue);
            context.SaveChanges();

            return(RedirectToAction("Index"));
        }