예제 #1
0
        public async ValueTask Setup()
        {
            _mapper            = Resolve <IMapper>();
            _leadRepository    = Resolve <ILeadRepository>();
            _accountRepository = Resolve <IAccountRepository>();
            _systemUnderTest   = new LeadController(_leadRepository, _accountRepository, _mapper, _urlOptions);
            await DropOrRestoreTestDbs("Dbs_Restore");

            _leadForTest      = (LeadInputModel)LeadInputModelMock.leadInputModel.Clone();
            _accountIMForTest = (AccountInputModel)AccountInputModelMock.accountInputModel.Clone();

            foreach (var item in LeadInputModelMock.leadsToInsertForSearchTest)
            {
                _leadsToInsertForSearch.Add((LeadInputModel)item.Clone());
            }

            foreach (var leadModel in _leadsToInsertForSearch)
            {
                ActionResult <LeadOutputModel> leadsInsertActionResult
                    = await _systemUnderTest.AddLead(leadModel);

                LeadOutputModel outputLead = AssertAndConvert(leadsInsertActionResult);
                leadModel.Id = outputLead.Id;
                _leadsForCompare.Add(outputLead);
                _accountIMForTest.LeadId = (long)outputLead.Id;
                ActionResult <AccountOutputModel> accountForSearchActionResult = await _systemUnderTest.AddAccount(_accountIMForTest);

                var accountForSearch = AssertAndConvert(accountForSearchActionResult);
                _accountsOMForTest.Add(accountForSearch);
            }
        }
        protected void grdMain_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "DetailPayment")
            {
                AgreementNumber = Convert.ToString(e.CommandArgument);
                //pnlDisclaimerDetails.Visible = true;
                PannelVisibility(true, true, true, false);
                BindGrid();
            }
            else if (e.CommandName == "SMSLead")
            {
                txtMsgSMS.Text  = "";
                AgreementNumber = Convert.ToString(e.CommandArgument);
                string jScript = "";
                jScript  = "$('#MsgBoxModal5').removeClass('hide');";
                jScript += "$('#masteroverlay5').removeClass('hide');";
                jScript += "$('#MsgBoxModal5').fadeIn(300);";
                ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "transfer_SMS", jScript, true);

                var  objPayment = new FitnessCenterEntities().Payments.FirstOrDefault(x => x.MembershipId == M);
                long LeadId     = objPayment.LeadId;
                Lead objLead    = LeadController.GetLeadById(LeadId);
                txtSmS.Text     = objLead.mobileNumber;
                txtMsgSMS.Text  = "Your Due Amount is: " + Convert.ToString(objPayment.remainingAmount);
                txtMsgSMS.Text += "\nPlease Paid Before This Date: " + objPayment.DueAmountDate;
            }
        }
 public void CanCreate()
 {
     var leadRepository = new Mock <IRepository <Contact> >();
     var userManager    = new Mock <IIdentityMembershipProvider>();
     var serverTime     = new Mock <IServerTime>();
     var controller     = new LeadController(leadRepository.Object, userManager.Object, serverTime.Object);
 }
예제 #4
0
        public async ValueTask TearDown()
        {
            _systemUnderTest = null;
            await DropOrRestoreTestDbs("Dbs_Drop");

            ShutdownIoC();
        }
        protected void grdExpiredMembers_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            try
            {
                if (e.CommandName == "SMSLead")
                {
                    txtMsgSMS.Text = "";
                    MembershipId   = Convert.ToInt64(e.CommandArgument.ToString());
                    string jScript = "";
                    jScript  = "$('#MsgBoxModal5').removeClass('hide');";
                    jScript += "$('#masteroverlay5').removeClass('hide');";
                    jScript += "$('#MsgBoxModal5').fadeIn(300);";
                    ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "transfer_SMS", jScript, true);

                    var  objMember = new FitnessCenterEntities().Memberships.FirstOrDefault(x => x.ID == MembershipId);
                    long LeadId    = objMember.LeadId;
                    Lead objLead   = LeadController.GetLeadById(LeadId);
                    txtSmS.Text     = objLead.mobileNumber;
                    txtMsgSMS.Text  = "YOUR EXPIRY DATE IS: " + objMember.ExpiryDate;
                    txtMsgSMS.Text += "\nPLEASE RENEW YOUR MEMBERSHIP BEFORE YOUR MEMBERSHIP EXPIRED";
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public void CanGetPageContactListFilteredOnTypeEmail()
        {
            var leadRepository = new LocalRepository <Contact>();
            var userManager    = new Mock <IIdentityMembershipProvider>();

            var date = new DateTime(2014, 10, 15, 15, 45, 33);

            leadRepository.Add(new Contact()
            {
                ClientId = 1, LeadType = "Phone", Date = date.AddDays(1)
            });
            leadRepository.Add(new Contact()
            {
                ClientId = 1, LeadType = "Email", Date = date.AddDays(2)
            });
            leadRepository.Add(new Contact()
            {
                ClientId = 1, LeadType = "Email", Date = date.AddDays(3)
            });
            leadRepository.Add(new Contact()
            {
                ClientId = 2, LeadType = "Phone", Date = date.AddDays(4)
            });

            var serverTime = new Mock <IServerTime>();

            serverTime.Setup(st => st.RequestStarted).Returns(new DateTime());

            var controller = new LeadController(leadRepository, userManager.Object, serverTime.Object);

            controller.Request = new HttpRequestMessage
            {
                RequestUri = new Uri("http://insidetest.helloy.se/api/client/1/contact/")
            };
            controller.Configuration = new HttpConfiguration();
            controller.Configuration.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional });

            controller.RequestContext.RouteData = new HttpRouteData(
                route: new HttpRoute(),
                values: new HttpRouteValueDictionary {
                { "ListContacts", "products" }
            });



            var response   = controller.GetContacts(1, type: "Email") as PageResult <Contact>;
            var resultList = response.results;

            Assert.AreEqual(2, resultList.Count());

            Assert.AreEqual("Email", resultList.ToArray()[0].LeadType);
            Assert.AreEqual("Email", resultList.ToArray()[1].LeadType);
        }
        public void CanGetLinkToNextPage()
        {
            var leadRepository = new LocalRepository <Contact>();
            var userManager    = new Mock <IIdentityMembershipProvider>();

            var date = new DateTime(2014, 10, 15, 15, 45, 33);

            leadRepository.Add(new Contact()
            {
                ClientId = 1, LeadType = "Phone", Date = date.AddDays(1)
            });
            for (int i = 0; i < 35; i++)
            {
                leadRepository.Add(new Contact()
                {
                    ClientId = 1, LeadType = "Phone", Date = date.AddDays(i)
                });
            }

            leadRepository.Add(new Contact()
            {
                ClientId = 2, LeadType = "Phone", Date = date.AddDays(4)
            });

            var serverTime = new Mock <IServerTime>();

            serverTime.Setup(st => st.RequestStarted).Returns(new DateTime());

            var controller = new LeadController(leadRepository, userManager.Object, serverTime.Object);

            controller.Request = new HttpRequestMessage
            {
                RequestUri = new Uri("http://insidetest.helloy.se/api/client/1/contact/?clientId=1")
            };
            controller.Configuration = new HttpConfiguration();
            controller.Configuration.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional });
            controller.Configuration.Routes.Add("ListContacts", new HttpRoute("api/client/{clientId}/contact/"));
            HttpRouteValueDictionary httpRouteValueDictionary = new HttpRouteValueDictionary {
                { "ListContacts", "products" }
            };

            controller.RequestContext.RouteData = new HttpRouteData(
                route: new HttpRoute(),
                values: httpRouteValueDictionary);

            var response   = controller.GetContacts(1) as PageResult <Contact>;
            var resultList = response.results;

            Assert.AreEqual(20, resultList.Count());
            Assert.IsTrue(String.IsNullOrEmpty(response.prevPageLink));
            Assert.IsFalse(String.IsNullOrEmpty(response.nextPageLink));
        }
예제 #8
0
 public void BindBirthday()
 {
     try
     {
         grdBirhtDay.DataSource = LeadController.GetBirthDay(LoginUser.ClubId, txtSearchName.Text, Dates, LoginUser.ID);
         grdBirhtDay.DataBind();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #9
0
 public void BindAppoinments()
 {
     try
     {
         grdLeadAppointment.DataSource = LeadController.GetLeadAppointmentByDate(LoginUser.ClubId, txtSearchName.Text, Dates, LoginUser.ID);
         grdLeadAppointment.DataBind();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #10
0
        public void Carregar()
        {
            Lead lead = new Lead();

            lead.clinina = UsuarioLogado;

            List <Lead> ll = new LeadController().Listar(lead);

            dgvLista.DataSource = ll;

            dgvLista.DataBind();
        }
예제 #11
0
 public void BindAnniversary()
 {
     try
     {
         grdAnniversary.DataSource = LeadController.GetAnniversary(LoginUser.ClubId, txtSearchName.Text, Dates, LoginUser.ID);
         grdAnniversary.DataBind();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #12
0
        private void UpdateUser()
        {
            try
            {
                User objUser = UsersController.GetUserByID(UserId);
                Lead objLead = LeadController.GetLeadByMobile(objUser.Mobile);



                if (objUser.UserTypeId == 7)
                {
                    objLead.mobileNumber = txtMobileNumber.Text;
                    objLead.firstName    = txtFirstName.Text;
                    objLead.lastName     = txtLastName.Text;
                    objLead.Email        = txtEmail.Text;
                    objLead.address      = txtAddress.Text;
                }
                objUser.FirstName  = txtFirstName.Text;
                objUser.LastName   = txtLastName.Text;
                objUser.UserTypeId = Convert.ToInt64(ddlRole.SelectedValue);
                //objUser.username = txtUsername.Text;
                objUser.Email    = txtEmail.Text;
                objUser.Mobile   = txtMobileNumber.Text;
                objUser.Password = txtPassword.Text;
                objUser.Address1 = txtAddress.Text;
                objUser.isActive = chkIsActive.Checked;

                objUser = new UsersController().UpdateUser(objUser);

                new UsersController().DeleteAccessMasterByUser(UserId);

                foreach (GridViewRow gr in grdManagePermissions.Rows)
                {
                    //hdnFldPageId,chkPermissions
                    HiddenField hdnFldPageId   = (HiddenField)gr.FindControl("hdnFldPageId");
                    CheckBox    chkPermissions = (CheckBox)gr.FindControl("chkPermissions");

                    if (chkPermissions.Checked)
                    {
                        AccessMaster objAccessMaster = new AccessMaster();
                        objAccessMaster.clubId   = LoginUser.ClubId;
                        objAccessMaster.userId   = objUser.ID;
                        objAccessMaster.updateBy = LoginUser.ID;
                        objAccessMaster.pageId   = Convert.ToInt64(hdnFldPageId.Value);
                        objAccessMaster          = new UsersController().InsertAccessMaster(objAccessMaster);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #13
0
        //public void BindPresentation()
        //{
        //    try
        //    {
        //        grdLeadPresentation.DataSource = LeadController.GetLeadPresentationByDate(LoginUser.ClubId, txtSearchName.Text, Dates);
        //        grdLeadPresentation.DataBind();
        //    }
        //    catch (Exception ex)
        //    {

        //        throw ex;
        //    }
        //}

        public void BindFollowup()
        {
            try
            {
                grdLeadFollowup.DataSource = LeadController.GetLeadFollowupByDate(LoginUser.ClubId, txtSearchName.Text, Dates, LoginUser.ID);
                grdLeadFollowup.DataBind();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #14
0
        protected void btnPesquisar_Click(object sender, EventArgs e)
        {
            Lead lead = new Lead();

            lead.clinina   = UsuarioLogado;
            lead.nome_lead = txtPesquisar.Text;

            List <Lead> ll = new LeadController().Listar(lead);

            dgvLista.DataSource = ll;

            dgvLista.DataBind();
        }
        public void CanGetLeadsOverAllAggregateForClientFillInMissingDates()
        {
            var leadRepository = new LocalRepository <Contact>();
            var userManager    = new Mock <IIdentityMembershipProvider>();
            var serverTime     = new Mock <IServerTime>();
            var endDate        = new DateTime(2013, 1, 31);

            serverTime.Setup(st => st.RequestStarted).Returns(endDate);

            leadRepository.Add(new Contact()
            {
                ClientId = 1, LeadType = "Phone", Date = endDate.AddMonths(-1)
            });
            leadRepository.Add(new Contact()
            {
                ClientId = 1, LeadType = "Email", Date = endDate.AddMonths(-1)
            });
            leadRepository.Add(new Contact()
            {
                ClientId = 1, LeadType = "Email", Date = endDate.AddMonths(-3)
            });
            leadRepository.Add(new Contact()
            {
                ClientId = 1, LeadType = "Phone", Date = endDate.AddMonths(-4)
            });

            leadRepository.Add(new Contact()
            {
                ClientId = 2, LeadType = "Phone", Date = endDate.AddMonths(-4)
            });

            var controller = new LeadController(leadRepository, userManager.Object, serverTime.Object);

            var leads = controller.GetLeadAggregate(1) as OkNegotiatedContentResult <LeadController.OverAllAggregate>;


            Assert.AreEqual(4, leads.Content.Total);
            Assert.AreEqual(0, leads.Content.Aggregates.Single(c => c.Year == 2013 && c.Month == 1).ContactCount);

            Assert.AreEqual(2, leads.Content.Aggregates.Single(c => c.Year == 2012 && c.Month == 12).ContactCount);

            Assert.AreEqual(0, leads.Content.Aggregates.Single(c => c.Year == 2012 && c.Month == 11).ContactCount);

            Assert.AreEqual(1, leads.Content.Aggregates.Single(c => c.Year == 2012 && c.Month == 10).ContactCount);

            Assert.AreEqual(1, leads.Content.Aggregates.Single(c => c.Year == 2012 && c.Month == 9).ContactCount);
        }
        public void CanGetLeadsAggregateForClientWithNoContactReturnsEmptyCurrentMonth()
        {
            var leadRepository = new LocalRepository <Contact>();
            var userManager    = new Mock <IIdentityMembershipProvider>();
            var serverTime     = new Mock <IServerTime>();
            var endDate        = new DateTime(2013, 1, 31);

            serverTime.Setup(st => st.RequestStarted).Returns(endDate);

            var controller = new LeadController(leadRepository, userManager.Object, serverTime.Object);

            var leads = controller.GetLeadAggregate(1) as OkNegotiatedContentResult <LeadController.OverAllAggregate>;

            Assert.AreEqual(0, leads.Content.Total);
            Assert.AreEqual(1, leads.Content.Aggregates.Count());
            Assert.AreEqual(0, leads.Content.Aggregates.Single(c => c.Year == 2013 && c.Month == 1).ContactCount);
        }
예제 #17
0
        protected void btnExportar_Click(object sender, EventArgs e)
        {
            Lead lead = new Lead();

            lead.origem_lead = dropOrigem.Text;
            lead.status      = dropStatus.Text;
            lead.clinina     = UsuarioLogado;

            List <Lead> ll = new LeadController().Exportar(lead);

            StringBuilder strDados = new StringBuilder(100000);

            // Itens necessários para importação
            strDados.Append("<html><head><META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=ISO-8859-1\"></head><body>");

            // Início da tabela
            strDados.Append("<table width='100%' style='font-family: Calibri; font-size: 12px;'>");

            // Cabeçalho da lista
            strDados.Append(String.Concat("<tr style='font-weight: bolder; color: white;'><td style='background-color: #5D7B9D;' align='left'>Nome</td><td style='background-color: #5D7B9D;' align='left'>Telefone</td><td style='background-color: #5D7B9D;' align='center'>Genero</td><td style='background-color: #5D7B9D;' align='left'>Data de Contato</td><td style='background-color: #5D7B9D;' align='left'>Origem</td><td style='background-color: #5D7B9D;' align='left'>Status</td>"));
            // Laço para incrementar a lista
            foreach (Lead item in ll)
            {
                strDados.Append("<tr>");

                strDados.Append(String.Concat("<td>", item.nome_lead, "</td>"));
                strDados.Append(String.Concat("<td>", item.fone_lead, "</td>"));
                strDados.Append(String.Concat("<td>", item.sexo_lead, "</td>"));
                strDados.Append(String.Concat("<td>", item.data_lead.ToString("dd/MM/yyyy"), "</td>"));
                strDados.Append(String.Concat("<td>", item.origem_lead, "</td>"));
                strDados.Append(String.Concat("<td>", item.status, "</td>"));

                strDados.Append("</tr>");
            }

            strDados.Append("</table>");
            strDados.Append("</body></html>");

            Response.Clear();
            Response.AddHeader("content-disposition", "attachment;filename=Relatorio.xls");
            Response.Charset = String.Empty;
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.ContentType = "application/vnd.xls";

            Response.Write(strDados.ToString());
        }
예제 #18
0
        public void Carregar()
        {
            Lead l = new Lead();

            l.idlead = int.Parse(Request.QueryString["itemSel"]);

            l.clinina = UsuarioLogado;

            l = new LeadController().ListarAlt(l)[0];

            ViewState.Add("itemSel", l);

            txtNome.Text    = l.nome_lead;
            txtTel.Text     = l.fone_lead;
            dropSexo.Text   = l.sexo_lead;
            dropOrigem.Text = l.origem_lead;
            dropStatus.Text = l.status;
        }
예제 #19
0
 public void BindMemberValues()
 {
     try
     {
         Membership objMember = AssignPTPController.GetmembersByID(MemberId);
         LeadId = objMember.LeadId;
         Lead objLead = LeadController.GetLeadById(LeadId);
         txtFirstname.Text = objLead.firstName;
         txtLastName.Text  = objLead.lastName;
         //txtDOB.Text = ((DateTime)objLead.dateOfBirth).ToString("dd/MM/yyyy");
         txtDOB.Text   = ((DateTime)objLead.dateOfBirth).ToString("dd/MM/yyyy");
         txtCntNo.Text = objLead.mobileNumber;
         //txtExpDate.Text = ((DateTime)objMember.expiryDate).ToString("dd/MM/yyyy");
         txtExpDate.Text = ((DateTime)objMember.ExpiryDate).ToString("dd/MM/yyyy");
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public void CanGetLeadsTypeAggregateForClientWithNoContactReturnsEmptyCurrentMonth()
        {
            var leadRepository = new LocalRepository <Contact>();
            var userManager    = new Mock <IIdentityMembershipProvider>();
            var serverTime     = new Mock <IServerTime>();
            var endDate        = new DateTime(2013, 1, 31);

            serverTime.Setup(st => st.RequestStarted).Returns(endDate);

            var controller = new LeadController(leadRepository, userManager.Object, serverTime.Object);

            var leads = controller.GetLeadTypeAggregateMonthly(1) as OkNegotiatedContentResult <IOrderedEnumerable <LeadController.MonthlyAggregateByType> >;

            Assert.AreEqual(1, leads.Content.Count());

            Assert.AreEqual(1, leads.Content.Count(c => c.Year == 2013 && c.Month == 1));
            Assert.IsNull(leads.Content.Single(c => c.Year == 2013 && c.Month == 1).Scores.AverageScore);
            Assert.AreEqual(0, leads.Content.Single(c => c.Year == 2013 && c.Month == 1).Count.Total);
            Assert.AreEqual(0, leads.Content.Single(c => c.Year == 2013 && c.Month == 1).Count.Phone);
            Assert.AreEqual(0, leads.Content.Single(c => c.Year == 2013 && c.Month == 1).Count.Email);
            Assert.AreEqual(0, leads.Content.Single(c => c.Year == 2013 && c.Month == 1).Count.Chat);
            Assert.AreEqual(0, leads.Content.Single(c => c.Year == 2013 && c.Month == 1).Count.Event);
        }
예제 #21
0
        //protected void btnNext1_Click(object sender, EventArgs e)

        protected void Details()
        {
            Membership objMember = DesclaimerController.GetDisclaimerByRFIDNo(MemberId);
            Lead       objLead   = LeadController.GetLeadById(objMember.LeadId);
            DateTime   dob;
            int        age = 0;

            txtRFIDCardNumber.Text = objMember.RFIDCardNumber;
            dob                     = (DateTime)objLead.dateOfBirth;
            age                     = DateTime.Now.Year;
            age                     = age - dob.Year;
            txtAge.Text             = Convert.ToString(age);
            txtDate.Text            = Convert.ToString(objLead.insertDate).Substring(0, 10);
            txtName.Text            = objLead.firstName;
            txtRegNumber.Text       = Convert.ToString(objMember.AgreementNo);
            txtAddress.Text         = objLead.address;
            txtCity.Text            = objLead.city;
            txtEmail.Text           = objLead.Email;
            txtMobileNumber.Text    = objLead.mobileNumber;
            txtSex.Text             = objLead.gender;
            lblAgreeNum.Text        = objMember.AgreementNo;
            lblTitle.Text           = objMember.Title + " " + objLead.firstName + " " + objLead.lastName + " ";
            pnlLeadsDetails.Visible = true;
            updtpnl1.Visible        = true;
            MeasurementPanelVisibility(true, false);
            pnlOffice.Visible       = true;
            pnlLeadsDetails.Visible = true;
            updtpnl1.Visible        = true;
            Pnlnext1.Visible        = false;
            pnlSave.Visible         = true;
            Disclaimer objDis = DesclaimerController.GetDisclaimerByMemberId(MemberId);

            txtRFIDCardNumber.Text = objMember.RFIDCardNumber;
            txtDate.Text           = Convert.ToString(DateTime.Now).Substring(0, 10);
            if (objDis == null)
            {
                txtHeight.Text     = "";
                txtWeight.Text     = "";
                txtFrameSize.Text  = "";
                txtName1.Text      = "";
                txtRelation1.Text  = "";
                txtMobileno1.Text  = "";
                txtLandline1.Text  = "";
                txtArea1.Text      = "";
                txtName2.Text      = "";
                txtRelation2.Text  = "";
                txtMobileno2.Text  = "";
                txtLandline2.Text  = "";
                txtArea2.Text      = "";
                txtName3.Text      = "";
                txtRelation3.Text  = "";
                txtMobileno3.Text  = "";
                txtLandline3.Text  = "";
                txtArea3.Text      = "";
                txtFamDocName.Text = "";
                txtFamDocNo.Text   = "";
            }
            else
            {
                txtHeight.Text     = objDis.height;
                txtWeight.Text     = objDis.weight;
                txtFrameSize.Text  = objDis.frameSize;
                txtName1.Text      = objDis.emergencyRefName1;
                txtRelation1.Text  = objDis.emergencyRefRelationship1;
                txtMobileno1.Text  = objDis.emergencyRefMobNo1;
                txtLandline1.Text  = objDis.emergencyRefLandLineNo1;
                txtArea1.Text      = objDis.emeregencyArea1;
                txtName2.Text      = objDis.emergencyRefName2;
                txtRelation2.Text  = objDis.emergencyRefRelationship2;
                txtMobileno2.Text  = objDis.emergencyRefMobNo2;
                txtLandline2.Text  = objDis.emergencyRefLandLineNo2;
                txtArea2.Text      = objDis.emeregencyArea2;
                txtName3.Text      = objDis.emergencyRefName3;
                txtRelation3.Text  = objDis.emergencyRefRelationship3;
                txtMobileno3.Text  = objDis.emergencyRefMobNo3;
                txtLandline3.Text  = objDis.emergencyRefLandLineNo3;
                txtArea3.Text      = objDis.emeregencyArea3;
                txtFamDocName.Text = objDis.familyDoctorName;
                txtFamDocNo.Text   = objDis.familyDoctorMobileNumber;



                // new DesclaimerController().UpdateDisclaimer(objDis);

                //BindQuestions();
            }
        }
 public LeadControllerTest()
 {
     _mockRepo = new Mock<IGenericRepository<Lead>>();
     _controller = new LeadController(_mockRepo.Object);
 }
        public void CanGetLeadsTypeAggregateForClientFillInMissingDates()
        {
            var leadRepository = new LocalRepository <Contact>();
            var userManager    = new Mock <IIdentityMembershipProvider>();
            var serverTime     = new Mock <IServerTime>();
            var endDate        = new DateTime(2013, 1, 31);

            serverTime.Setup(st => st.RequestStarted).Returns(endDate);

            leadRepository.Add(new Contact()
            {
                ClientId    = 1,
                LeadType    = "Phone",
                Date        = endDate.AddMonths(-1),
                RatingScore = 3
            });
            leadRepository.Add(new Contact()
            {
                ClientId    = 1,
                LeadType    = "Email",
                Date        = endDate.AddMonths(-1),
                RatingScore = 5
            });
            leadRepository.Add(new Contact()
            {
                ClientId = 1, LeadType = "Email", Date = endDate.AddMonths(-3)
            });
            leadRepository.Add(new Contact()
            {
                ClientId    = 1,
                LeadType    = "Phone",
                Date        = endDate.AddMonths(-4),
                RatingScore = 4
            });

            leadRepository.Add(new Contact()
            {
                ClientId = 2, LeadType = "Phone", Date = endDate.AddMonths(-4)
            });

            var controller = new LeadController(leadRepository, userManager.Object, serverTime.Object);

            var leads = controller.GetLeadTypeAggregateMonthly(1) as OkNegotiatedContentResult <IOrderedEnumerable <LeadController.MonthlyAggregateByType> >;

            Assert.AreEqual(5, leads.Content.Count());

            Assert.AreEqual(1, leads.Content.Count(c => c.Year == 2013 && c.Month == 1));
            Assert.IsNull(leads.Content.Single(c => c.Year == 2013 && c.Month == 1).Scores.AverageScore);
            Assert.AreEqual(0, leads.Content.Single(c => c.Year == 2013 && c.Month == 1).Count.Total);
            Assert.AreEqual(0, leads.Content.Single(c => c.Year == 2013 && c.Month == 1).Count.Phone);
            Assert.AreEqual(0, leads.Content.Single(c => c.Year == 2013 && c.Month == 1).Count.Email);
            Assert.AreEqual(0, leads.Content.Single(c => c.Year == 2013 && c.Month == 1).Count.Chat);
            Assert.AreEqual(0, leads.Content.Single(c => c.Year == 2013 && c.Month == 1).Count.Event);

            Assert.AreEqual(1, leads.Content.Count(c => c.Year == 2012 && c.Month == 12));
            Assert.AreEqual(4, leads.Content.Single(c => c.Year == 2012 && c.Month == 12).Scores.AverageScore);
            Assert.AreEqual(2, leads.Content.Single(c => c.Year == 2012 && c.Month == 12).Count.Total);
            Assert.AreEqual(1, leads.Content.Single(c => c.Year == 2012 && c.Month == 12).Count.Phone);
            Assert.AreEqual(1, leads.Content.Single(c => c.Year == 2012 && c.Month == 12).Count.Email);
            Assert.AreEqual(0, leads.Content.Single(c => c.Year == 2012 && c.Month == 12).Count.Chat);
            Assert.AreEqual(0, leads.Content.Single(c => c.Year == 2012 && c.Month == 12).Count.Event);

            Assert.AreEqual(1, leads.Content.Count(c => c.Year == 2012 && c.Month == 11));
            Assert.IsNull(leads.Content.Single(c => c.Year == 2012 && c.Month == 11).Scores.AverageScore);
            Assert.AreEqual(0, leads.Content.Single(c => c.Year == 2012 && c.Month == 11).Count.Total);
            Assert.AreEqual(0, leads.Content.Single(c => c.Year == 2012 && c.Month == 11).Count.Phone);
            Assert.AreEqual(0, leads.Content.Single(c => c.Year == 2012 && c.Month == 11).Count.Email);
            Assert.AreEqual(0, leads.Content.Single(c => c.Year == 2012 && c.Month == 11).Count.Chat);
            Assert.AreEqual(0, leads.Content.Single(c => c.Year == 2012 && c.Month == 11).Count.Event);

            Assert.AreEqual(1, leads.Content.Count(c => c.Year == 2012 && c.Month == 10));
            Assert.IsNull(leads.Content.Single(c => c.Year == 2012 && c.Month == 10).Scores.AverageScore);
            Assert.AreEqual(1, leads.Content.Single(c => c.Year == 2012 && c.Month == 10).Count.Total);
            Assert.AreEqual(0, leads.Content.Single(c => c.Year == 2012 && c.Month == 10).Count.Phone);
            Assert.AreEqual(1, leads.Content.Single(c => c.Year == 2012 && c.Month == 10).Count.Email);
            Assert.AreEqual(0, leads.Content.Single(c => c.Year == 2012 && c.Month == 10).Count.Chat);
            Assert.AreEqual(0, leads.Content.Single(c => c.Year == 2012 && c.Month == 10).Count.Event);

            Assert.AreEqual(1, leads.Content.Count(c => c.Year == 2012 && c.Month == 9));
            Assert.AreEqual(4, leads.Content.Single(c => c.Year == 2012 && c.Month == 9).Scores.AverageScore);
            Assert.AreEqual(1, leads.Content.Single(c => c.Year == 2012 && c.Month == 9).Count.Total);
            Assert.AreEqual(1, leads.Content.Single(c => c.Year == 2012 && c.Month == 9).Count.Phone);
            Assert.AreEqual(0, leads.Content.Single(c => c.Year == 2012 && c.Month == 9).Count.Email);
            Assert.AreEqual(0, leads.Content.Single(c => c.Year == 2012 && c.Month == 9).Count.Chat);
            Assert.AreEqual(0, leads.Content.Single(c => c.Year == 2012 && c.Month == 9).Count.Event);
        }