public ActionResult InternalComments([FromBody] InternalCommentsDTO InternalCommentsDTO) { if (!ModelState.IsValid) { return BadRequest(); } if (InternalCommentsDTO == null) { return BadRequest(); } var checkInternalCommentIdinDb = _choiceRepoistory.GetInternalComments().Find(c => c.InternalCommentsId == InternalCommentsDTO.InternalCommentsId); if (checkInternalCommentIdinDb != null) { return BadRequest(); } InternalComments newlyInternalComments = new InternalComments() { InternalCommentsId = InternalCommentsDTO.InternalCommentsId, BookingId = InternalCommentsDTO.BookingId, Comments = InternalCommentsDTO.Comments, InternalNotifyId = InternalCommentsDTO.InternalNotifyId, CreatedDate = InternalCommentsDTO.CreatedDate, CreatedBy = InternalCommentsDTO.CreatedBy, SharepointId = InternalCommentsDTO.SharepointId, }; _choiceRepoistory.SetInternalComments(newlyInternalComments); _choiceRepoistory.Complete(); return CreatedAtRoute("GetInternalComments", new { comments = newlyInternalComments.Comments }, newlyInternalComments); }
public void SetInternalComments(InternalComments InternalComments) { _dbContext.InternalComments.Add(InternalComments); }
public void InsertData(ClientContext clientContext, DKBSDbContext dbContext) { try { Console.WriteLine(" Successfully Connected"); SP.List oListData = clientContext.Web.Lists.GetByTitle("Service request notes"); ListItemCollectionPosition position = null; var page = 1; do { CamlQuery camlQuery = new CamlQuery(); camlQuery.ViewXml = "<View Scope='Recursive'><Query></Query><RowLimit>5000</RowLimit></View>"; camlQuery.ListItemCollectionPosition = position; ListItemCollection oListDataItem = oListData.GetItems(camlQuery); clientContext.Load(oListDataItem); clientContext.ExecuteQuery(); position = oListDataItem.ListItemCollectionPosition; foreach (ListItem oItem in oListDataItem) { Console.WriteLine("ID: {0} \nTitle: {1}", oItem["ID"], oItem["Title"]); Console.WriteLine(((SP.FieldUserValue)(oItem["Author"])).LookupValue); Console.WriteLine(((SP.FieldUserValue)(oItem["Editor"])).LookupValue); Console.WriteLine(oItem["Created"].ToString()); Console.WriteLine(oItem["Modified"].ToString()); Console.WriteLine(oItem["Action"]); Console.WriteLine(oItem["ScheduleAction"]); Console.WriteLine(oItem["PlannedStart"]); Console.WriteLine(oItem["Notify"]); Console.WriteLine(oItem["PlannedEnd"]); Console.WriteLine(oItem["CopyToCloseRemark"]); if (oItem["ServiceRequestID"] != null) { Console.WriteLine(oItem["ServiceRequestID"]); var childIdField = oItem["ServiceRequestID"] as FieldLookupValue[]; if (childIdField != null) { foreach (var lookupValue in childIdField) { var childId_Value = lookupValue.LookupValue; var childId_Id = lookupValue.LookupId; Console.WriteLine("LookupID: " + childId_Id.ToString()); Console.WriteLine("LookupValue: " + childId_Value.ToString()); } } } if (oItem["CloseField"] != null) { Console.WriteLine(oItem["CloseField"]); var childIdField = oItem["CloseField"] as FieldLookupValue[]; if (childIdField != null) { foreach (var lookupValue in childIdField) { var childId_Value = lookupValue.LookupValue; var childId_Id = lookupValue.LookupId; Console.WriteLine("LookupID: " + childId_Id.ToString()); Console.WriteLine("LookupValue: " + childId_Value.ToString()); } } } InternalComments internalComments = new InternalComments(); internalComments.BookingId = 7; if (oItem["Action"] != null) { internalComments.Comments = oItem["Action"].ToString(); } // internalComments.InternalNotifyId = 1; if (oItem["ID"] != null) { internalComments.SharepointId = Convert.ToInt32(oItem["ID"]); } if (oItem["Author"] != null) { internalComments.CreatedBy = ((SP.FieldUserValue)(oItem["Author"])).LookupValue; } if (oItem["Created"] != null) { internalComments.CreatedDate = Convert.ToDateTime(oItem["Created"].ToString()); } dbContext.Add(internalComments); dbContext.SaveChanges(); } page++; }while (position != null); } catch (Exception) { throw; } }