public async Task <IActionResult> AddToProjectAsync([FromBody] AddToProjectViewModel model) { if (model.Email == null) { return(BadRequest()); } var user = await _userManager.FindByEmailAsync(model.Email); // TODO: CHECK IF IN LIST AND SEND FAILURE if (user != null) { var result = new ProjectMember { Employee = user, IsCreator = false, AcceptedInvitation = false, ProjectId = model.ProjectId, ShowOnlyMine = false }; _context.Add(result); if (_context.SaveChanges() > 0) { return(new JsonResult("success")); } else { return(BadRequest()); } } return(NotFound()); }
public void SaveUserComplaint(UserComplaintModel userComplaint) { log.Info(">>> User Complaint save method entered"); DbContext.UserComplaint.Add(userComplaint); DbContext.SaveChanges(); log.Info(">>>User Complaint details have been saved. "); }
private async Task LoadXmlDocumentAsync(Guid projectId, NewProjectViewModel model, string docName) { using (var memoryStream = new MemoryStream()) { await model.File.CopyToAsync(memoryStream); memoryStream.Position = 0; XmlDocument docs = new XmlDocument(); docs.Load(memoryStream); XmlNodeList dataNodes = docs.GetElementsByTagName("data"); var lang = await _context.Languages.Where(w => w.Id == model.LanguageId).SingleOrDefaultAsync(); var project = await _context.Projects.Where(x => x.Id == projectId).SingleOrDefaultAsync(); var doc = await _context.DocumentTypes.Where(w => w.Name == ".xml").SingleOrDefaultAsync(); var projectDocument = new ProjectDocument { Name = docName, Language = lang, Project = project, DocumentType = doc, AddedDate = DateTime.Now }; _context.Add(projectDocument); if (_context.SaveChanges() > 0) { foreach (XmlNode item in dataNodes) { var nodeId = item.Attributes["name"].Value; var nodeValue = item.SelectSingleNode("value").InnerText; var dictionary = new ProjectDocumentDictionary { Document = projectDocument, Name = nodeId, Value = nodeValue }; _context.Add(dictionary); } await _context.SaveChangesAsync(); } } }
/// <summary> /// User Registration data Saved. /// </summary> /// <param name="user"></param> /// <returns></returns> public bool SaveUserDetails(UserDetails user) { log.Debug("### SaveUserDetails"); dbContext.Configuration.ValidateOnSaveEnabled = false; dbContext.Users.Add(user); dbContext.SaveChanges(); log.Info(">>>> Data has been saved"); return(true); }