GetItemsAsync() публичный статический Метод

public static GetItemsAsync ( Expression, predicate ) : Task>
predicate Expression,
Результат Task>
Пример #1
0
        private async Task AddtoDatabase(Activity message, string TeamorConversationId, string mebId)
        {
            var user = new UserDetails();

            //var TeamorConversationId = channelData.Team != null ? channelData.Team.Id : message.Conversation.Id;
            user.EmaildId = await GetUserEmailId(mebId, message.ServiceUrl, TeamorConversationId);

            user.UserId   = mebId;
            user.UserName = await GetUserName(mebId, message.ServiceUrl, TeamorConversationId);

            if (user.UserName != null)
            {
                user.UserName = user.UserName.Split(' ').FirstOrDefault();
            }
            user.Type = Helper.Constants.NewUser;
            var existinguserRecord = await DocumentDBRepository.GetItemsAsync <UserDetails>(u => u.EmaildId == user.EmaildId && u.Type == Helper.Constants.NewUser);

            if (existinguserRecord.Count() == 0)
            {
                var NewUserRecord = await DocumentDBRepository.CreateItemAsync(user);
            }
        }
Пример #2
0
        public async static Task <ComposeExtensionResponse> HandleMessageExtensionQuery(Activity activity)
        {
            var query = activity.GetComposeExtensionQueryData();

            if (query == null || query.CommandId != "search")
            {
                // We only process the 'getRandomText' queries with this message extension
                return(null);
            }

            var title      = "";
            var titleParam = query.Parameters?.FirstOrDefault(p => p.Name == "searchText");

            if (titleParam != null)
            {
                title = titleParam.Value.ToString().ToLower();
            }

            var attachments = new List <ComposeExtensionAttachment>();

            var passengers = await DocumentDBRepository <Passenger> .GetItemsAsync(d => d != null && (d.Name.ToLower().Contains(title) || d.Seat.ToLower().Contains(title)));


            foreach (var passenger in passengers)
            {
                var card    = O365CardHelper.GetO365ConnectorCard(passenger);
                var preview = O365CardHelper.GetPreviewCard(passenger);

                attachments.Add(card
                                .ToAttachment()
                                .ToComposeExtensionAttachment(preview.ToAttachment()));
            }

            var response = new ComposeExtensionResponse(new ComposeExtensionResult("list", "result"));

            response.ComposeExtension.Attachments = attachments.ToList();

            return(response);
        }
Пример #3
0
        public void ItemsAreRetrieved()
        {
            _documentDBRepository.CreateItemAsync(new Dummy
            {
                Id   = Guid.NewGuid(),
                Name = "DUMMY05"
            }).Wait();

            _documentDBRepository.CreateItemAsync(new Dummy
            {
                Id   = Guid.NewGuid(),
                Name = "DUMMY05"
            }).Wait();

            var items = _documentDBRepository.GetItemsAsync(d => d.Name == "DUMMY05").Result.ToList();

            Assert.Equal(2, items.Count);
            foreach (var item in items)
            {
                _documentDBRepository.DeleteItemAsync(item.Id.ToString()).Wait();
            }
        }
Пример #4
0
        public async Task <String> SetViewBags()
        {
            string bm = (string)Session["BridgeModule"];

            ViewBag.LMEDItemNo = await DocumentDBRepository.GetItemsAsync <BList>(d => d.Tag == "BList" && d.BridgeModule == bm && d.ListType == "MEDItemNo");

            ViewBag.LPTPs = await DocumentDBRepository.GetItemsAsync <BProdTechPara>(d => d.Tag == "BProdTechPara" && d.BridgeModule == bm);

            if (bm == "M3")
            {
                Job J = await DocumentDBRepository.GetItemAsync <Job>("4e5a1ffe-df4a-4146-9d82-acc196b7a6ee");

                ViewBag.Job = J;
                var ps = await DocumentDBRepository.GetItemsAsync <Product>(d => d.Tag == "Product" && d.DbJobId == J.Id);

                ViewBag.Product = ps.FirstOrDefault();
            }

            ViewBag.LPTPs = await DocumentDBRepository.GetItemsAsync <BProdTechPara>(d => d.Tag == "BProdTechPara" && d.BridgeModule == bm);

            return("");
        }
Пример #5
0
        public async Task <ActionResult> EditAsync(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            BEmail item = await DocumentDBRepository.GetItemAsync <BEmail>(id);

            if (item == null)
            {
                return(HttpNotFound());
            }
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var j = await DocumentDBRepository.GetItemAsync <Job>("93ffbdaa-72bd-4df8-a154-d140a73ef700");

            ViewBag.Job = j;
            var i = await DocumentDBRepository.GetItemAsync <IORA>("38ea1592-88d9-4c53-a6d9-b571b1c37532");

            ViewBag.IORA = i;
            var f = await DocumentDBRepository.GetItemsAsync <BFinancial>(d => d.Tag == "BFinancial" && d.BridgeModule == i.BridgeModule && d.CertType == j.CertType);

            ViewBag.FinancialSet = f.FirstOrDefault();
            var u = await DocumentDBRepository.GetItemAsync <BUser>("8864ba7d-8593-4eb5-88c0-0b224e24567f");

            ViewBag.TargetUser = u;

            if (item == null)
            {
                return(HttpNotFound());
            }

            return(View(item));
        }
Пример #6
0
        private static async Task MarkFreeAirCraft(AirCraftDetails aircardInfo, Activity replyActivity)
        {
            var aircraftInfo = await DocumentDBRepository <AirCraftInfo> .GetItemsAsync(d => d.FlightNumber == aircardInfo.FlightNumber && d.AircraftId == aircardInfo.AircraftId);

            if (aircraftInfo.Count() > 0)
            {
                try
                {
                    var list = aircraftInfo.FirstOrDefault();

                    list.Status = Status.Available;
                    var aircraftDetails = await DocumentDBRepository <AirCraftInfo> .UpdateItemAsync(list.Id, list);

                    var replyCard = O365CardHelper.GetO365ConnectorCardResult(aircraftInfo.FirstOrDefault(), aircardInfo.ActionId);
                    replyActivity.Attachments.Add(replyCard.ToAttachment());
                    //replyActivity.Text = $"Aircraft {aircardInfo.AircraftId} is available";
                }
                catch (Exception e)
                {
                    replyActivity.Text = e.Message.ToString();
                }
            }
        }
        private async Task ShowPendingApprovals(IDialogContext context, Activity activity, Employee employee)
        {
            var pendingLeaves = await DocumentDBRepository.GetItemsAsync <LeaveDetails>(l => l.Type == LeaveDetails.TYPE);

            pendingLeaves = pendingLeaves.Where(l => l.ManagerEmailId == employee.EmailId && l.Status == LeaveStatus.Pending);
            if (pendingLeaves.Count() == 0)
            {
                var reply = activity.CreateReply();
                reply.Text = "No pending leaves for approval.";
                await context.PostAsync(reply);
            }
            else
            {
                var reply = activity.CreateReply();
                reply.Text = "Here are all the leaves pending for approval:";
                foreach (var leave in pendingLeaves)
                {
                    var attachment = EchoBot.ManagerViewCard(employee, leave);
                    reply.Attachments.Add(attachment);
                }
                await context.PostAsync(reply);
            }
        }
Пример #8
0
        public async Task <ActionResult> EditAsync(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TechCheckLSA ii = await DocumentDBRepository.GetItemAsync <TechCheckLSA>(id);

            Job j = await DocumentDBRepository.GetItemAsync <Job>(ii.DbJobId);

            ViewBag.Job           = j;
            ViewBag.BTechCheckLSA = await DocumentDBRepository.GetItemsAsync <BTechChecklist>(d => d.Tag == "BTechChecklist" && d.BridgeModule == ii.BridgeModule && d.TemplateName == "TechCheckLSA");

            ViewBag.LUser = await DocumentDBRepository.GetItemsAsync <BUser>(d => d.Tag == "BUser" && (d.BridgesGranted).Contains(ii.BridgeModule));


            if (ii == null)
            {
                return(HttpNotFound());
            }

            return(View(ii));
        }
        /// <summary>

        /// Signs the user out from AAD

        /// </summary>

        public static async Task Signout(string emailId, IDialogContext context)

        {
            context.ConversationData.Clear();

            await context.SignOutUserAsync(ApplicationSettings.ConnectionName);

            await DocumentDBRepository.DeleteItemAsync(emailId);



            var pendingLeaves = await DocumentDBRepository.GetItemsAsync <LeaveDetails>(l => l.Type == LeaveDetails.TYPE);

            foreach (var leave in pendingLeaves.Where(l => l.AppliedByEmailId == emailId))

            {
                await DocumentDBRepository.DeleteItemAsync(leave.LeaveId);
            }



            await context.PostAsync($"We have cleared everything related to you.");
        }
Пример #10
0
        private async Task <Customer> AddCustomerInfoIfNoneAsync(Job j)
        {
            var lcustomer = await DocumentDBRepository.GetItemsAsync <Customer>(cs => cs.Tag == "Customer" && cs.CustomerId == j.CustomerId);

            if (lcustomer.Count() == 0)
            {
                Customer c = new Customer()
                {
                    CustomerId   = j.CustomerId,
                    CustomerName = j.CustomerName,
                    Address      = "xx",
                    Email        = "xx@xx",
                };
                var d = await DocumentDBRepository.CreateItemAsync <Customer>(c);

                string cid = new BListController().GetIdFromDocument(d.ToString());
                return(await DocumentDBRepository.GetItemAsync <Customer>(cid));
            }
            else
            {
                return(lcustomer.FirstOrDefault());
            }
        }
Пример #11
0
        public async Task AddPEDProductByProdName(string jobid, string prodName)
        {
            string bm   = (string)Session["BridgeModule"];
            var    LPTP = await DocumentDBRepository.GetItemsAsync <BProdTechPara>(bp => bp.Tag == "BProdTechPara" && bp.ProdName == prodName && bp.BridgeModule == bm);

            Product newP = new Product()
            {
                DbJobId      = jobid,
                BridgeModule = bm,
                ProdName     = prodName,
                PTPs         = new List <ProdTechPara>(),
            };

            foreach (BProdTechPara ptp in LPTP)
            {
                ProdTechPara newptp = new ProdTechPara()
                {
                    TechParaName  = ptp.TechParaName,
                    TechParaValue = ptp.DefaultValue,
                };
                newP.PTPs.Add(newptp);
            }
            await DocumentDBRepository.CreateItemAsync <Product>(newP);
        }
Пример #12
0
        private static async Task ShowAircraftDetails(AirCraftDetails aircraft, Activity replyActivity)
        {
            var list = await DocumentDBRepository <AirCraftInfo> .GetItemsAsync(d => d.FlightNumber == aircraft.FlightNumber && d.BaseLocation.ToLower() == aircraft.BaseLocation.ToLower());/* && d.JourneyDate.ToShortDateString()==flighinput.JourneyDate.ToShortDateString());*/

            if (list.Count() > 0)
            {
                var aircraftModels = list.FirstOrDefault();

                var aircraftDetails = await DocumentDBRepository <AirCraftInfo> .GetItemsAsync(d => d.FlightType.ToLower() == aircraftModels.FlightType.ToLower() && d.BaseLocation.ToLower() == aircraft.BaseLocation.ToLower());/* && d.JourneyDate.ToShortDateString()==flighinput.JourneyDate.ToShortDateString());*/

                if (aircraftDetails.Count() > 0)
                {
                    var ListCard = AddListCardAttachment(replyActivity, aircraftDetails);
                }
                else
                {
                    replyActivity.Text = $"Aircraft not available for selected base location and flight number.";
                }
            }
            else
            {
                replyActivity.Text = $"Aircraft not available for selected base location and flight number.";
            }
        }
Пример #13
0
        public async Task <ActionResult> CommonIndex(string searchString, string userSig)
        {
            if (string.IsNullOrEmpty(userSig))
            {
                userSig = (string)Session["UserSignature"];
            }
            ViewBag.userSig = userSig;

            string bm      = (string)Session["BridgeModule"];
            var    myModel = await DocumentDBRepository.GetItemsAsync <Job>(d => d.Tag == "Job" && d.BridgeModule.ToUpper() == bm && d.TaskHandler.ToUpper() == userSig && d.IsComplete == false);

            if (!String.IsNullOrEmpty(searchString))
            {
                searchString.Replace(" ", "");
                searchString = searchString.ToLower();

                myModel = myModel.Where(s => s.NpsJobId.ToLower().Contains(searchString) || (s.CustomerName + "X").ToLower().Contains(searchString) || (s.ProdDescription + "X").ToLower().Contains(searchString) || (s.CertType + "X").ToLower().Contains(searchString));
            }
            await SetViewBags();

            myModel = myModel.OrderBy(s => s.NpsJobId);

            return(View((string)Session["BridgeModule"] + "_Index", myModel));
        }
Пример #14
0
        public async Task <HttpResponseMessage> Add(Movie movie)
        {
            var userName = Request.GetHeaderValue("username");

            if (string.IsNullOrWhiteSpace(userName))
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, "Required request header username is missing"));
            }

            var existingUser = await DocumentDBRepository <UserDetails> .GetItemsAsync(d =>
                                                                                       d.UserName == userName);

            if (existingUser == null || existingUser.FirstOrDefault() == null)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.Unauthorized, "Unauthorized User"));
            }

            var userId = existingUser.FirstOrDefault().Id;

            existingUser.FirstOrDefault().AddtoMovies(movie);
            await DocumentDBRepository <UserDetails> .UpdateItemAsync(userId, existingUser.FirstOrDefault()).ConfigureAwait(false);

            return(Request.CreateResponse(HttpStatusCode.OK));
        }
Пример #15
0
        public async Task <string> SetViewBags()
        {
            var bm  = (string)Session["BridgeModule"];
            var jid = (string)Session["DbJobId"];

            var lbb = await DocumentDBRepository.GetItemsAsync <BBridge>(d => d.Tag == "BBridge" && d.BridgeName == bm);

            ViewBag.bridge = lbb.FirstOrDefault();

            var lct = await DocumentDBRepository.GetItemsAsync <BFinancial>(d => d.Tag == "BFinancial" && d.BridgeModule == bm);

            lct = lct.OrderBy(d => d.CertType);
            ViewBag.LCertType = lct;

            var lca = await DocumentDBRepository.GetItemsAsync <BList>(d => d.Tag == "BList" && d.BridgeModule == bm && d.ListType == "CertAction");

            lca = lca.OrderBy(d => d.ListItem);
            ViewBag.LCertAction = lca;

            var lvalueSource = await DocumentDBRepository.GetItemsAsync <BList>(d => d.Tag == "BList" && d.BridgeModule == bm && (d.ListType.ToLower().Contains("autocomplete") || d.ListType.ToLower().Contains("dropdown")));

            ViewBag.LValueSource = lvalueSource;

            var lmp = await DocumentDBRepository.GetItemsAsync <BList>(d => d.Tag == "BList" && d.BridgeModule == bm && d.ListType == "MainProdType");

            lmp = lmp.OrderBy(d => d.ListItem);
            ViewBag.LMainProdType = lmp;

            var lsp = await DocumentDBRepository.GetItemsAsync <BList>(d => d.Tag == "BList" && d.BridgeModule == bm && d.ListType == "SubProdType");

            lsp = lsp.OrderBy(d => d.ListItem);
            ViewBag.LSubProdType = lsp;

            var lmed = await DocumentDBRepository.GetItemsAsync <BList>(d => d.Tag == "BList" && d.BridgeModule == bm && d.ListType == "MEDItemNo");

            lmed = lmed.OrderBy(d => d.ListItem);
            ViewBag.LMEDItemNo = lmed;

            var lu = await DocumentDBRepository.GetItemsAsync <BUser>(d => d.Tag == "BUser" && (d.BridgesGranted).Contains(bm));

            lu            = lu.OrderBy(d => d.Signature);
            ViewBag.LUser = lu;

            if (bm == "M3" && !string.IsNullOrEmpty(jid))
            {
                Job j = await DocumentDBRepository.GetItemAsync <Job>(jid);

                ViewBag.LPTP = await DocumentDBRepository.GetItemsAsync <BProdTechPara>(d => d.Tag == "BProdTechPara" && d.BridgeModule == bm && d.ProdName == j.MEDItemNo);

                ViewBag.LProduct = await DocumentDBRepository.GetItemsAsync <Product>(d => d.Tag == "Product" && d.DbJobId == jid);

                var LAutoCertText = await DocumentDBRepository.GetItemsAsync <BLSACert>(d => d.Tag == "BLSACert" && d.BridgeModule == bm && d.BookMarkName == j.MEDItemNo);

                //Sort autotxt by sequence order
                LAutoCertText         = LAutoCertText.OrderBy(d => d.Description);
                ViewBag.LAutoCertText = LAutoCertText;
            }
            else if (bm == "M2" && !string.IsNullOrEmpty(jid))
            {
                Job j = await DocumentDBRepository.GetItemAsync <Job>(jid);

                ViewBag.LPTP = await DocumentDBRepository.GetItemsAsync <BProdTechPara>(d => d.Tag == "BProdTechPara" && d.BridgeModule == bm);

                ViewBag.LProduct = await DocumentDBRepository.GetItemsAsync <Product>(d => d.Tag == "Product" && d.DbJobId == jid);
            }

            return("");
        }
Пример #16
0
        public async Task <ActionResult> CommonTask1(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Job item = await DocumentDBRepository.GetItemAsync <Job>(id);

            if (item == null)
            {
                return(HttpNotFound());
            }

            item.StatusNote      = "";
            item.SendingFlag     = "-";
            Session["DbJobId"]   = item.Id;
            Session["NpsJobId"]  = item.NpsJobId;
            Session["MEDItemNo"] = item.MEDItemNo;
            //Temp. solution. to be fixed
            if (item.BridgeModule == "M3")
            {
                if (!(item.MEDItemNo == "MED/3.16" && item.CertType == "MED"))
                {
                    item.CertType  = "MED";
                    item.MEDItemNo = "MED/3.16";
                    await DocumentDBRepository.UpdateItemAsync <Job>(item.Id, item);
                }

                var lproduct = await DocumentDBRepository.GetItemsAsync <Product>(d => d.Tag == "Product" && d.DbJobId == id);

                if (lproduct.Count() == 0)
                {
                    Product p = new Product()
                    {
                        BridgeModule = item.BridgeModule,
                        ProdName     = item.MEDItemNo,
                        DbJobId      = item.Id,
                        PTPs         = new List <ProdTechPara>(),
                    };
                    await DocumentDBRepository.CreateItemAsync <Product>(p);

                    lproduct = await DocumentDBRepository.GetItemsAsync <Product>(d => d.Tag == "Product" && d.DbJobId == id);
                }

                ViewBag.LProduct = lproduct;

                var LAutoCertText = await DocumentDBRepository.GetItemsAsync <BLSACert>(d => d.Tag == "BLSACert" && d.BridgeModule == item.BridgeModule);

                LAutoCertText         = LAutoCertText.OrderBy(d => d.Description);
                ViewBag.LAutoCertText = LAutoCertText;
            }

            if (item.BridgeModule == "M2" && !string.IsNullOrEmpty(item.CertType) && (item.CertType == "PED" || item.CertType == "TPED"))
            {
                ViewBag.Customer = await AddCustomerInfoIfNoneAsync(item);

                var LCustomer = await DocumentDBRepository.GetItemsAsync <Customer>(d => d.Tag == "Customer" && d.CustomerId == item.CustomerId);

                ViewBag.LCustomerAddr    = LCustomer.GroupBy(x => x.Address).Select(x => x.Last()).ToList();
                ViewBag.LCustomerContact = LCustomer.GroupBy(x => x.Email).Select(x => x.Last()).ToList();

                await AddPEDProductstoJobIfNone(item.Id);
                await SetViewBags();

                return(View((string)Session["BridgeModule"] + "_Task1_PED", item));
            }

            await SetViewBags();

            return(View((string)Session["BridgeModule"] + "_Task1", item));
        }
Пример #17
0
        public async Task <ActionResult> IndexAsync()
        {
            var items = await DocumentDBRepository <Student> .GetItemsAsync(d => !d.Stud_Valid || d.Stud_Valid);

            return(View(items));
        }
Пример #18
0
        private void FillInitialData()
        {
            var list = _context.GetItemsAsync(y => y.Name != "").Result.ToList();

            if (list.Count > 0)
            {
                return;
            }
            var x = _context.CreateItemAsync(new Customer()
            {
                Name    = "Kalles Grustransporter AB",
                Address = new Address()
                {
                    City = "Södertälje", Details = "Cementvägen 8, 111 11"
                },
                Vehicles = new Vehicle[] { new Vehicle()
                                           {
                                               VehicleId          = "YS2R4X20005399401",
                                               RegistrationNumber = "ABC123"
                                           }, new Vehicle()
                                           {
                                               VehicleId          = "VLUR4X20009093588",
                                               RegistrationNumber = "DEF456"
                                           }, new Vehicle()
                                           {
                                               VehicleId          = "VLUR4X20009048066",
                                               RegistrationNumber = "GHI789"
                                           } }
            });

            x = _context.CreateItemAsync(new Customer()
            {
                Name    = "Johans Bulk AB",
                Address = new Address()
                {
                    City = "Stockholm", Details = "Balkvägen 12, 222 22"
                },
                Vehicles = new Vehicle[] { new Vehicle()
                                           {
                                               VehicleId          = "YS2R4X20005388011",
                                               RegistrationNumber = "JKL012"
                                           }, new Vehicle()
                                           {
                                               VehicleId          = "YS2R4X20005387949",
                                               RegistrationNumber = "MNO345"
                                           } }
            });

            x = _context.CreateItemAsync(new Customer()
            {
                Name    = "Haralds Värdetransporter AB",
                Address = new Address()
                {
                    City = "Uppsala", Details = "Budgetvägen 1, 333 33"
                },
                Vehicles = new Vehicle[] { new Vehicle()
                                           {
                                               VehicleId          = "YS2R4X20005387765",
                                               RegistrationNumber = "PQR678"
                                           }, new Vehicle()
                                           {
                                               VehicleId          = "YS2R4X20005387055",
                                               RegistrationNumber = "STU901"
                                           } }
            });
        }
Пример #19
0
        public async Task <ActionResult> IndexAsync()
        {
            var s = await DocumentDBRepository <BingUser> .GetItemsAsync(d => d.Tag == "BingUser");

            return(View(s));
        }
Пример #20
0
        public async Task <ActionResult> IndexAsync()
        {
            var items = await DocumentDBRepository <UserPost> .GetItemsAsync();

            return(View(items));
        }
Пример #21
0
        public async Task <IEnumerable <Lesson> > GetLessonsListAsync()
        {
            IEnumerable <Lesson> value = await DocumentDBRepository <Lesson> .GetItemsAsync();

            return(value);
        }
        public async Task <int> Count()
        {
            var allSubscriptions = await DocumentDBRepository <PushSubscriptionInformation> .GetItemsAsync(s => s.EndPoint != null);

            return(allSubscriptions.Count <PushSubscriptionInformation>());
        }
Пример #23
0
        public async Task <ActionResult> IndexAsync()
        {
            var items = await DocumentDBRepository <WebsiteProperties> .GetItemsAsync();

            return(View(items));
        }
        public async Task <ActionResult> Index(string Emailid)

        {
            if (Emailid != null)
            {
                Emailid = Emailid.ToLower();

                var readEmployee = await DocumentDBRepository.GetItemAsync <Employee>(Emailid);

                DateTime nextholiday;

                foreach (var item in PublicHolidaysList.HolidayList)
                {
                    if (item.Date.Date > DateTime.Now.Date)

                    {
                        nextholiday = item.Date.Date;
                    }
                }

                if (readEmployee != null)
                {
                    readEmployee.IsManager = await RootDialog.IsManager(readEmployee);

                    if (!string.IsNullOrEmpty(readEmployee.ManagerEmailId))
                    {
                        var managername = await DocumentDBRepository.GetItemAsync <Employee>(readEmployee.ManagerEmailId);

                        if (managername != null)
                        {
                            readEmployee.ManagerName = managername.DisplayName;

                            readEmployee.AzureADId = managername.AzureADId;
                        }
                    }
                }
                else
                {
                    return(View());
                }

                List <LeaveExtended> leaveDetails = null;

                var readLeave = await DocumentDBRepository.GetItemsAsync <LeaveExtended>(e => e.Type == LeaveDetails.TYPE && e.AppliedByEmailId == Emailid);

                if (readLeave != null)
                {
                    readEmployee.Totalleaves = 0;

                    foreach (var item in readLeave)

                    {
                        TimeSpan diff = item.EndDate.Date.Subtract(item.StartDate.Date);

                        item.DaysDiff = Convert.ToInt32(diff.TotalDays);

                        item.startDay = item.StartDate.Date.ToString("dddd");

                        item.EndDay = item.EndDate.Date.ToString("dddd");

                        item.StartDateval = item.StartDate.Date.ToString("MMM d");

                        item.EndDateVal = item.EndDate.Date.ToString("MMM d");

                        if (item.Status == LeaveStatus.Approved)
                        {
                            readEmployee.Totalleaves += item.DaysDiff;
                        }
                    }

                    leaveDetails = readLeave.ToList();
                }

                List <ManagerDetails> mrgLeavedata = null;

                var managerleave = await DocumentDBRepository.GetItemsAsync <ManagerDetails>(e => e.Type == LeaveDetails.TYPE && e.ManagerEmailId == Emailid && e.Status == 0);

                if (managerleave != null)
                {
                    foreach (var item in managerleave)
                    {
                        TimeSpan diff1 = item.EndDate.Date.Subtract(item.StartDate.Date);

                        item.mgrDaysdiff = Convert.ToInt32(diff1.TotalDays);

                        item.mgrstartDay = item.StartDate.Date.ToString("ddd");

                        item.mgrEndDay = item.EndDate.Date.ToString("ddd");

                        item.mgrStartDateval = item.StartDate.Date.ToString("MMM d");

                        item.mgrEndDateVal = item.EndDate.Date.ToString("MMM d");

                        var managerresource = await DocumentDBRepository.GetItemsAsync <Employee>(e => e.Type == Employee.TYPE && e.EmailId == item.AppliedByEmailId);

                        if (managerresource != null)

                        {
                            foreach (var name in managerresource)

                            {
                                item.ResourceName = name.DisplayName;
                            }
                        }
                    }

                    mrgLeavedata = managerleave.ToList();
                }

                return(View(Tuple.Create(readEmployee, leaveDetails, mrgLeavedata)));
            }
            else

            {
                return(View());
            }
        }
Пример #25
0
        public async Task <IEnumerable <Hero> > GetAsync()
        {
            IEnumerable <Hero> value = await DocumentDBRepository <Hero> .GetItemsAsync();

            return(value);
        }
Пример #26
0
        public async Task <ActionResult> IndexAsync()
        {
            var items = await DocumentDBRepository.GetItemsAsync <TechCheckLSA>(d => d.Tag == "TechCheckLSA");

            return(View(items));
        }
        public async Task <ActionResult> IndexAsync()
        {
            var items = await DocumentDBRepository <ItemViewModel> .GetItemsAsync(d => !d.Completed);

            return(View(items));
        }
Пример #28
0
        public async Task <IActionResult> Index()
        {
            var items = await DocumentDBRepository <LogItem> .GetItemsAsync(d => !d.Completed);

            return(View(items));
        }
        public async Task <ActionResult> Create(string Emailid)
        {
            User user1 = new User()
            {
                BotConversationId = "id1", Id = "*****@*****.**", Name = "User 1"
            };
            User user2 = new User()
            {
                BotConversationId = "id2", Id = "*****@*****.**", Name = "User 2"
            };
            User user3 = new User()
            {
                BotConversationId = "id3", Id = "*****@*****.**", Name = "User 3"
            };
            Group group1 = new Group()
            {
                Id    = "GroupId1",
                Name  = "Group 1",
                Users = new List <string>()
                {
                    user1.Id, user2.Id
                }
            };
            Group group2 = new Group()
            {
                Id    = "GroupId2",
                Name  = "Group 2",
                Users = new List <string>()
                {
                    user2.Id, user3.Id
                }
            };

            Team team1 = new Team()
            {
                Id       = "Team1",
                Name     = "Team1",
                Channels = new List <Channel>()
                {
                    new Channel()
                    {
                        Id = "channel1", Name = "Channel 1"
                    },
                    new Channel()
                    {
                        Id = "channel2", Name = "Channel 2"
                    },
                    new Channel()
                    {
                        Id = "channel3", Name = "Channel 3"
                    },
                }
            };

            Team team2 = new Team()
            {
                Id       = "Team2",
                Name     = "Team2",
                Channels = new List <Channel>()
                {
                    new Channel()
                    {
                        Id = "channel1", Name = "Channel 1"
                    },
                    new Channel()
                    {
                        Id = "channel2", Name = "Channel 2"
                    },
                    new Channel()
                    {
                        Id = "channel3", Name = "Channel 3"
                    },
                }
            };

            Tenant tenant = new Tenant()
            {
                Id     = "Tenant1",
                Groups = new List <string>()
                {
                    group1.Id, group2.Id
                },
                Users = new List <string>()
                {
                    user1.Id, user2.Id, user3.Id
                },
                Teams = new List <string>()
                {
                    team1.Id, team2.Id
                }
            };

            Campaign campaignAnnouncement = new Campaign()
            {
                IsAcknowledgementRequested = true,
                IsContactAllowed           = true,
                Title    = "Giving Campaign 2018 is here",
                SubTitle = "Have you contributed to the mission?",
                Author   = new Author()
                {
                    Name = "John Doe",
                    Role = "Director of Corporate Communications",
                },
                Preview     = "The 2018 Employee Giving Campaign is officially underway! Our incredibly generous culture of employee giving is unique to Contoso, and has a long history going back to our founder and his family’s core belief and value in philanthropy. Individually and collectively, we can have an incredible impact no matter how we choose to give. We are all very fortunate and 2018 has been a good year for the company which we are all participating in. Having us live in a community with a strong social safety net benefits us all so lets reflect our participation in this year's success with participation in Give.",
                Body        = "The 2018 Employee Giving Campaign is officially underway! Our incredibly generous culture of employee giving is unique to Contoso, and has a long history going back to our founder and his family’s core belief and value in philanthropy. Individually and collectively, we can have an incredible impact no matter how we choose to give. We are all very fortunate and 2018 has been a good year for the company which we are all participating in. Having us live in a community with a strong social safety net benefits us all so lets reflect our participation in this year's success with participation in Give. I hope you will take advantage of some of the fun and impactful opportunities that our giving team has put together and I’d like to thank our VPALs John Doe and Jason Natie for all the hard work they've put into planning these events for our team. To find out more about these opportunities, look for details in Give 2018",
                ImageUrl    = "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSG-vkjeuIlD-up_-VHCKgcREhFGp27lDErFkveBLQBoPZOHwMbjw",
                Sensitivity = MessageSensitivity.Information
            };

            campaignAnnouncement.Id       = "Announcement3";
            campaignAnnouncement.TenantId = tenant.Id;

            var recipients = new RecipientInfo();

            recipients.Channels.Add(new ChannelRecipient()
            {
                TeamId  = team1.Id,
                Channel = new RecipientDetails()
                {
                    Id = "channel1",
                }
            });

            recipients.Channels.Add(new ChannelRecipient()
            {
                TeamId  = team2.Id,
                Channel = new RecipientDetails()
                {
                    Id = "channel2",
                }
            });

            recipients.Groups.Add(new GroupRecipient()
            {
                GroupId = group1.Id,
                Users   = new List <RecipientDetails>()
                {
                    new RecipientDetails()
                    {
                        Id = user1.Id,
                    },
                    new RecipientDetails()
                    {
                        Id = user2.Id,
                    },
                }
            });
            campaignAnnouncement.Recipients = recipients;
            campaignAnnouncement.Status     = Status.Draft;

            // Insert
            //await DocumentDBRepository.CreateItemAsync(user1);
            //await DocumentDBRepository.CreateItemAsync(user2);

            // Udpate
            //user1.Name += "Updated";
            //await DocumentDBRepository.UpdateItemAsync(user1.EmailId, user1);

            //await DocumentDBRepository.CreateItemAsync(group1);
            //await DocumentDBRepository.CreateItemAsync(group2);

            //await DocumentDBRepository.CreateItemAsync(team1);
            //await DocumentDBRepository.CreateItemAsync(team2);

            //await DocumentDBRepository.CreateItemAsync(tenant);

            await DocumentDBRepository.CreateItemAsync(campaignAnnouncement);

            // Update announcements.
            tenant.Announcements.Add(campaignAnnouncement.Id);
            await DocumentDBRepository.UpdateItemAsync(campaignAnnouncement.Id, campaignAnnouncement);

            var allGroups = await DocumentDBRepository.GetItemsAsync <Group>(u => u.Type == nameof(Group));

            var allTeam = await DocumentDBRepository.GetItemsAsync <Team>(u => u.Type == nameof(Team));

            var allTenants = await DocumentDBRepository.GetItemsAsync <Tenant>(u => u.Type == nameof(Tenant));

            var allAnnouncements = await DocumentDBRepository.GetItemsAsync <Campaign>(u => u.Type == nameof(Campaign));

            var myTenantAnnouncements = allAnnouncements.Where(a => a.TenantId == tenant.Id);

            return(View());
        }
Пример #30
0
        public async Task <IEnumerable <string> > GetNames()
        {
            var users = await DocumentDBRepository <User> .GetItemsAsync(u => true);

            return(users.Select(u => u.UserName));
        }