Пример #1
0
        internal static bool UpdatetTicket(string id, Ticket value, string username)
        {
            var contextDB = MongoDBHelper.GetContext(ConnectionString, DB);
            var objUser = GetUser(username);

            //var listComments = (from comm in value.Comments
            //                    //where string.IsNullOrEmpty(comm.Id)
            //                    select new BsonDocument {
            //                    //{ "Id", comm.Id },
            //                    { "Title", comm.Title },
            //                    { "DateCreation", comm.DateCreation },
            //                    { "InsertBy", comm.InsertBy },
            //                    { "Text", comm.Text }
            //                    }).ToArray();
            IMongoUpdate update;
            if (objUser.IsAdmin)
            {
                update = Update
                   .Set("AssignedUser", value.AssignedUser)
                   .Set("Closed", value.Closed)
                   .Set("DateClosed", value.DateClosed)
                   .Set("Description", value.Description)
                   .Set("Title", value.Title)
                   .Set("IsRead", false);
            }
            else
            {
                update = Update
                        .Set("AssignedUser", value.AssignedUser)
                        .Set("Closed", value.Closed)
                        .Set("DateClosed", value.DateClosed)
                        .Set("Description", value.Description)
                        .Set("Title", value.Title);
            }

            return MongoDBHelper.Modify(contextDB, TicketCollection, id, update);
        }
Пример #2
0
 internal static string InsertTicket(Ticket value)
 {
     var contextDB = MongoDBHelper.GetContext(ConnectionString, DB);
     return MongoDBHelper.Insert<Ticket>(contextDB, TicketCollection, value);
 }