public bool CreateOrUpdateBug(Bug model)
        {
            try
            {
                var bug = context.Bugs
                          .Where(p => p.Id == model.Id)
                          .FirstOrDefault();

                if (bug != null)
                {
                    //bug exists, update basic info
                    bug.Reporter    = model.Reporter;
                    bug.AssigneeId  = model.AssigneeId;
                    bug.ProjectId   = model.ProjectId;
                    bug.Title       = model.Title;
                    bug.Description = model.Description;
                    bug.Status      = model.Status;
                    bug.Priority    = model.Priority;
                    bug.DueDate     = model.DueDate;
                }
                else
                {
                    //model.DateCreated = DateTime.Now;
                    context.Bugs.Add(model);
                }
                context.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                LogError("CreateOrUpdateBug error", ex);
                return(false);
            }
        }
        public bool CreateOrUpdateProject(Project model)
        {
            try
            {
                var dbProject = context.Projects
                                .Where(p => p.Id == model.Id)
                                .FirstOrDefault();

                if (dbProject != null)
                {
                    //project exists, update basic info
                    dbProject.Description = model.Description;
                    dbProject.Name        = model.Name;
                    dbProject.CreatorId   = model.CreatorId;
                }
                else
                {
                    context.Projects.Add(model);
                }
                context.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                LogError("CreateOrUpdateProject error", ex);
                return(false);
            }
        }
Exemple #3
0
 public void Post([FromBody] User user)
 {
     _dbContext.Add(user);
     _dbContext.SaveChanges();
 }