public ActionResult CreateChatCommunication([FromBody] ChatCommunicationDTO chatCommunicationDTO)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            if (chatCommunicationDTO == null)
            {
                return(BadRequest());
            }

            var checkChatIdinDb = _choiceRepoistory.GetChatCommunication().Find(c => c.ChatId == chatCommunicationDTO.ChatId);

            if (checkChatIdinDb != null)
            {
                return(BadRequest());
            }

            ChatCommunications newlyChatCommunication = new ChatCommunications()
            {
                //ChatId = chatCommunicationDTO.ChatId,
                ChatTitle                  = chatCommunicationDTO.ChatTitle,
                BookingId                  = chatCommunicationDTO.BookingId,
                ChatCommunication          = chatCommunicationDTO.ChatCommunication,
                ProcedureId                = chatCommunicationDTO.ProcedureId,
                IsPartnerSideCommunication = chatCommunicationDTO.IsPartnerSideCommunication,
                ProcedureCommunication     = chatCommunicationDTO.ProcedureCommunication,
                CreatedDate                = chatCommunicationDTO.CreatedDate,
                CreatedBy                  = chatCommunicationDTO.CreatedBy,
                SharepointId               = chatCommunicationDTO.SharepointId
            };

            _choiceRepoistory.SetChatCommunication(newlyChatCommunication);
            _choiceRepoistory.Complete();
            return(CreatedAtRoute("GetChatCommunicationByChatId", new { chatId = newlyChatCommunication.ChatId }, newlyChatCommunication));
        }
Esempio n. 2
0
 public void SetChatCommunication(ChatCommunications chatCommunication)
 {
     _dbContext.ChatCommunication.Add(chatCommunication);
 }
Esempio n. 3
0
        public void InsertData(ClientContext clientContext, DKBSDbContext dbContext)
        {
            try
            {
                Console.WriteLine(" Successfully Connected");

                SP.List   oListData = clientContext.Web.Lists.GetByTitle("Service request communications");
                CamlQuery camlQuery = new CamlQuery();
                camlQuery.ViewXml = "<View Scope='RecursiveAll'><Query></Query></View>";
                ListItemCollection oListDataItem = oListData.GetItems(camlQuery);

                clientContext.Load(oListDataItem);

                clientContext.ExecuteQuery();

                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["Communications"]);
                    Console.WriteLine(oItem["FromMyIT"]);
                    Console.WriteLine(oItem["Created"]);
                    Console.WriteLine(oItem["CopyToCloseRemark"]);
                    Console.WriteLine(oItem["IsPartnerSideCommunication"]);
                    Console.WriteLine(oItem["ProcedureInfoCommunication"]);
                    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["ITProcedureID"] != null)
                    {
                        Console.WriteLine(oItem["ITProcedureID"]);
                        var childIdField = oItem["ITProcedureID"] 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());
                            }
                        }
                    }
                    ChatCommunications chatCommunications = new ChatCommunications();
                    if (oItem["Title"] != null)
                    {
                        chatCommunications.ChatTitle = oItem["Title"].ToString();
                    }
                    else
                    {
                        chatCommunications.ChatTitle = "No Chat Title";
                    }
                    chatCommunications.BookingId = 7;
                    if (oItem["Communications"] != null)
                    {
                        chatCommunications.ChatCommunication = oItem["Communications"].ToString();
                    }
                    chatCommunications.ProcedureId = 2;
                    if (oItem["IsPartnerSideCommunication"] != null)
                    {
                        chatCommunications.IsPartnerSideCommunication = Convert.ToBoolean(oItem["IsPartnerSideCommunication"]);
                    }
                    if (oItem["ProcedureInfoCommunication"] != null)
                    {
                        chatCommunications.ProcedureCommunication = Convert.ToBoolean(oItem["ProcedureInfoCommunication"]);
                    }
                    if (oItem["ID"] != null)
                    {
                        chatCommunications.SharepointId = Convert.ToInt32(oItem["ID"]);
                    }
                    chatCommunications.CreatedBy   = ((SP.FieldUserValue)(oItem["Author"])).LookupValue;
                    chatCommunications.CreatedDate = Convert.ToDateTime(oItem["Created"].ToString());

                    dbContext.Add(chatCommunications);
                    dbContext.SaveChanges();
                }
            }
            catch (Exception)
            {
                throw;
            }
        }