public ActionResult List(UserViewModel viewModel)
        {
            var users = new GenericService<User>(new GenericRepository<User>(new NHibernateRepositoryContext())).Select(null, viewModel.MyGrid);

            viewModel.MyGrid.Columns = GridColumn.Create("Name", "Nome completo", "Salary", "Salário", "BirthDate", "Data de nascimento");
            viewModel.MyGrid.DataSource = users;
            viewModel.MyGrid.DataBind();

            var blogs = new GenericService<WebLog>(new GenericRepository<WebLog>(new NHibernateRepositoryContext())).Select(null, viewModel.MyGrid2);
            viewModel.MyGrid2.Columns = GridColumn.Create("Title", "Título", "Creator", "Criador", "CreatedAt", "Criado em");
            viewModel.MyGrid2.DataSource = blogs;
            viewModel.MyGrid2.DataBind();

            return View("List", viewModel);
        }
Esempio n. 2
0
        public static List <MenuDTO> getMenuDT(String menuType)
        {
            if (HttpContext.Current.Application[menuType] != null)
            {
                return(HttpContext.Current.Application[menuType] as List <MenuDTO>);
            }

            DataTable             dt    = GenericService.getVewImageNewMasterDT();
            IEnumerable <DataRow> query =
                from dr in dt.AsEnumerable()
                where dr.Field <String>("SKUCategory") == menuType &&
                dr.Field <String>("CategoryTypeID") != null &&
                dr.Field <String>("CategoryTypeID") != String.Empty
                orderby dr.Field <String>("SKUCategory")
                select dr;

            try
            {
                query = query.Distinct(new DistictComparer("CategoryTypeID"));
                dt    = query.CopyToDataTable <DataRow>();
            }
            catch (InvalidOperationException e)
            {
                Logger.Error("Exception occur HomeService.getMenuDT()", e);
                dt = new DataTable();
            }
            List <MenuDTO> dtos = new List <MenuDTO>();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                MenuDTO dto = new MenuDTO();
                dto.Heading = dt.Rows[i]["SKUCategoryType"] + "";
                dto.Url     = ConfigUtil.hostURL() + "" + dt.Rows[i]["CategoryTypeUrlName"] + "";
                DataTable dt1 = CategoriesService.getDistictProductByCatType(dt.Rows[i]["CategoryTypeID"] + "");
                for (int j = 0; j < dt1.Rows.Count; j++)
                {
                    MenuDTO subDto = new MenuDTO();
                    subDto.Heading = dt1.Rows[j]["SKUProductType"] + "";
                    string str = StringUtil.urlEncode(dt1.Rows[j]["SKUProductType"] + "");
                    subDto.Url = dto.Url + "/" + str;

                    dto.addContent(subDto);
                }
                dtos.Add(dto);
                HttpContext.Current.Application[menuType] = dtos;
            }
            return(dtos);
        }
Esempio n. 3
0
        public List <StaffHome_VM> GetHighlights()
        {
            List <StaffHome_VM> listHn = new List <StaffHome_VM>();
            var auction = GenericService.GetAll().OrderByDescending(p => p.CreateTime).Take(2).ToList();

            foreach (Highlights na in auction)
            {
                StaffHome_VM hn = new StaffHome_VM();
                hn.Id         = na.ID;
                hn.Name       = na.AuctionName;
                hn.Type       = "HighlightList.aspx";
                hn.CreateTime = na.CreateTime;
                listHn.Add(hn);
            }
            return(listHn);
        }
Esempio n. 4
0
        public List <StaffHome_VM> GetHomeOnline()
        {
            List <StaffHome_VM> listHn = new List <StaffHome_VM>();
            var online = GenericService.GetAll().OrderByDescending(p => p.CreateTime).Take(2).ToList();

            foreach (OnlineVote na in online)
            {
                StaffHome_VM hn = new StaffHome_VM();
                hn.Id         = na.ID;
                hn.Name       = na.Title;
                hn.Type       = "NY_Online.aspx";
                hn.CreateTime = na.CreateTime;
                listHn.Add(hn);
            }
            return(listHn);
        }
Esempio n. 5
0
        public void ResolveNamedInstance()
        {
            var genA = new GenericService {
                Name = "genA"
            };
            var genB = new GenericService {
                Name = "genB"
            };
            var c = CreateContainer();

            c.RegisterInstance <IGenericService>(genA, "genA");
            c.RegisterInstance <IGenericService>(genB, "genB");

            Assert.Same(genA, c.Resolve <IGenericService>("genA"));
            Assert.Same(genB, c.Resolve <IGenericService>("genB"));
        }
Esempio n. 6
0
        public static DataTable getMenuItemDT(String menuType)
        {
            DataTable             dt    = GenericService.getVewImageNewMasterDT();
            IEnumerable <DataRow> query =
                from dr in dt.AsEnumerable()
                where dr.Field <String>("CategoryTypeID") == menuType
                orderby dr.Field <String>("SKUProductType")
                select dr;

            try
            {
                query = query.Distinct(new DistictComparer("ProductTypeID"));
                dt    = query.CopyToDataTable <DataRow>();
            }
            catch { }
            return(dt);
        }
Esempio n. 7
0
        private void LoadUsersGrid()
        {
            var users = new GenericService <User>().GetAll().Select(u => new { userID = u.UserID, userName = u.UserName });

            dgvUsers.DataSource = users;

            if (users.ToList().Count == 0)
            {
                return;
            }

            dgvUsers.Columns["userID"].IsVisible = false;

            dgvUsers.Columns["userName"].Width               = 400;
            dgvUsers.Columns["userName"].HeaderText          = "Name";
            dgvUsers.Columns["userName"].HeaderTextAlignment = ContentAlignment.MiddleLeft;
        }
Esempio n. 8
0
        internal static async Task <ResponseBase <List <OnScreenClick> > > DashboardWidgetClick(TeamHttpContext teamHttpContext, OnScreenClick details)
        {
            try
            {
                if (teamHttpContext == null)
                {
                    throw new ArgumentNullException(nameof(teamHttpContext));
                }
                List <OnScreenClick> GridData = await GenericService.GetGridDataAsync(teamHttpContext, details).ConfigureAwait(false);

                return(GetTypedResponse(teamHttpContext, GridData));
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Esempio n. 9
0
        public static DataTable searchBrand(string like)
        {
            like = like.ToLower();
            //List<string> list= new List<string>();
            DataTable resultDT = new DataTable();
            DataTable dt       = GenericService.getVewImageNewMasterDT();;
            var       v        = (from DataRow dr in dt.Rows
                                  where dr.Field <String>("SKUBrand").ToLower().StartsWith(like)
                                  select dr);

            try{
                //list=v.ToList<string>();
                resultDT = v.Distinct(new DistictComparer("SKUBrand")).CopyToDataTable <DataRow>();
            }catch {
            }
            return(resultDT);
        }
Esempio n. 10
0
        public ActionResult loginAccess(ecom_tbl_User _log)
        {
            string OldHASHValue = string.Empty;
            IGenericService <ecom_tbl_User> _igenericService = new GenericService <ecom_tbl_User>();

            ecom_tbl_User _logInfo = new ecom_tbl_User();

            if (ModelState.IsValid)
            {
                if (_log != null && _log.Password != null && _log.Email != null)
                {
                    _logInfo = _igenericService.GetFirstOrDefault(filter: q => q.Email == _log.Email && q.Password == _log.Password);
                    if (_logInfo != null)
                    {
                        OldHASHValue = _logInfo.PasswordHashKey == null ? new Cipher().Encrypt(_log.Email + _log.Password) : _logInfo.PasswordHashKey;
                        if (OldHASHValue != null)
                        {
                            bool isLogin = CompareHashValue(_log.Email.ToString(), _log.Password, OldHASHValue);

                            if (isLogin)
                            {
                                //Login Success
                                //For Set Authentication in Cookie (Remeber ME Option)
                                SignInRemember(_logInfo.Email.ToString(), false);

                                Session["User_Email"] = _logInfo.Email;
                                Session["User_Name"]  = _logInfo.UserName;
                                Session["UserID"]     = _logInfo.UserId;

                                //Set A Unique ID in session
                                if (_logInfo.UserRole == "Admin")
                                {
                                    return(Json(new { redirectionURL = "/Admin/Dashboard/Index", loginfo = _logInfo }, JsonRequestBehavior.AllowGet));
                                }
                                else
                                {
                                    return(Json(new { redirectionURL = "/Customer/Admin_Category", loginfo = _logInfo }, JsonRequestBehavior.AllowGet));
                                }
                            }
                        }
                    }
                }
            }
            return(Json(new { res = false }, JsonRequestBehavior.AllowGet));
        }
Esempio n. 11
0
        public static DataTable getSizeDT(string style, bool isStyle)
        {
            DataTable             dt    = GenericService.getVewImageNewMasterDT();
            IEnumerable <DataRow> query = null;

            query =
                from dr in dt.AsEnumerable()
                where dr.Field <String>("StyleCode") == style
                orderby dr.Field <String>("Size")
                select dr;


            try
            {
                query = query.Distinct(new DistictComparer("Size"));
                dt    = query.CopyToDataTable <DataRow>();
            }
            catch (InvalidOperationException e)
            {
                query = from dr in GenericService.getVewImageNewMasterDT().AsEnumerable()
                        where dr.Field <String>("SKUCode") == style
                        orderby dr.Field <String>("Size")
                        select dr;

                try
                {
                    query = query.Distinct(new DistictComparer("Size"));
                    dt    = query.CopyToDataTable <DataRow>();
                    query = from dr in GenericService.getVewImageNewMasterDT().AsEnumerable()
                            where dr.Field <String>("StyleCode") == dt.Rows[0]["StyleCode"] + ""
                            orderby dr.Field <String>("Size")
                            select dr;

                    query = query.Distinct(new DistictComparer("Size"));
                    dt    = query.CopyToDataTable <DataRow>();
                }
                catch {
                    Logger.Error("Exception ocuur CatDetailsService.getSizeDT()", e);
                    dt = new DataTable();
                }

                return(dt);
            }
            return(dt);
        }
Esempio n. 12
0
        public static List <MenuDTO> getBrandMenuDT()
        {
            if (HttpContext.Current.Application[Constant.Application.BRAND_MENU] != null)
            {
                return(HttpContext.Current.Application[Constant.Application.BRAND_MENU] as List <MenuDTO>);
            }

            DataTable             dt    = GenericService.getVewImageNewMasterDT();
            IEnumerable <DataRow> query =
                from dr in dt.AsEnumerable()
                select dr;

            try
            {
                query = query.Distinct(new DistictComparer("SKUCategory"));
                dt    = query.CopyToDataTable <DataRow>();
            }
            catch (InvalidOperationException e)
            {
                Logger.Error("Exception occur HomeService.getMenuDT()", e);
                dt = new DataTable();
            }
            List <MenuDTO> dtos = new List <MenuDTO>();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                MenuDTO dto = new MenuDTO();
                dto.Heading = dt.Rows[i]["SKUCategory"] + "";
                dto.Url     = ConfigUtil.hostURL() + "" + dt.Rows[i]["SKUCategory"] + "";
                DataTable dt1 = CategoriesService.getDistictProductByCat(dt.Rows[i]["SKUCategory"] + "");
                for (int j = 0; j < dt1.Rows.Count; j++)
                {
                    MenuDTO subDto = new MenuDTO();
                    subDto.Heading = dt1.Rows[j]["SKUBrand"] + "";
                    subDto.Url     = ConfigUtil.hostURL() + "Shop-By-Brand/" + dt1.Rows[j]["SKUCategoryType"] + "?Brand=" + dt1.Rows[j]["SKUBrand"];
                    dto.addContent(subDto);
                }
                dtos.Add(dto);
                if (dtos != null)
                {
                    HttpContext.Current.Application[Constant.Application.BRAND_MENU] = dtos;
                }
            }
            return(dtos);
        }
Esempio n. 13
0
        public ActionResult GetAllEmp(int PageNumber = 1, int PageSize = 3)
        {
            EmployeeCVModel emp = new EmployeeCVModel();
            GenericService  act = new GenericService();

            SqlParameter[] parameters =
            {
                new SqlParameter("@EmpID",      SqlDbType.NVarChar, 12)
                {
                    Value = emp.EmpID ?? (object)DBNull.Value
                },
                new SqlParameter("@VLastName",  SqlDbType.NVarChar, 100)
                {
                    Value = emp.VLastName ?? (object)DBNull.Value
                },
                new SqlParameter("@VFirstName", SqlDbType.NVarChar, 100)
                {
                    Value = emp.VFirstName ?? (object)DBNull.Value
                },
                new SqlParameter("@NickName",   SqlDbType.NVarChar, 50)
                {
                    Value = emp.NickName ?? (object)DBNull.Value
                },
                new SqlParameter("@DOB",        SqlDbType.NVarChar, 50)
                {
                    Value = emp.DOB ?? (object)DBNull.Value
                },
                new SqlParameter("@Gender",     SqlDbType.NVarChar, 1)
                {
                    Value = emp.Gender ?? (object)DBNull.Value
                },
                new SqlParameter("@Email",      SqlDbType.NVarChar, 50)
                {
                    Value = emp.Email ?? (object)DBNull.Value
                },
                new SqlParameter("@ACTION",     "SelectAll")
                //new SqlParameter("@PageNumber",PageNumber),
                //new SqlParameter("@PageSize",PageSize)
            };
            //DataSet ds = act.crud("sp_InsertUpdateDelete_tblEmpCV", parameters);
            DataSet ds = act.Generic("sp_InsertUpdateDelete_tblEmpCV", parameters);

            ViewBag.emp = ds.Tables[0];
            return(View(new EmployeeCVModel()));
        }
Esempio n. 14
0
 public OrderViewModel(GenericService <Order> orderService, GenericService <Room> roomService, GenericService <Client> clientService, GenericService <Service> serviceService)
 {
     service             = orderService;
     this.roomService    = roomService;
     this.clientService  = clientService;
     this.serviceService = serviceService;
     WorkingItem         = new Order();
     finishOrderCommand  = new DelegateCommand((o) => { if (SelectedItem == null)
                                                        {
                                                            return;
                                                        }
                                                        SelectedItem.FinishOrder(); service.Update(SelectedItem); SelectedItem.Room.State = RoomState.Free; roomService.Update(SelectedItem.Room); NotifyPropertyChanged("Items"); Update(); });
     useServiceCommand = new DelegateCommand((o) => { if (SelectedItem == null || SelectedItem.EndDate == null || Service == null)
                                                      {
                                                          return;
                                                      }
                                                      SelectedItem.UseService(Service); service.Update(SelectedItem);  NotifyPropertyChanged("Items"); });
 }
Esempio n. 15
0
        public void Generic_Update_Product_NotFound_Service()
        {
            var fakeContext = new FakeContext("Generic_Update_Product_NotFound_Service");

            fakeContext.FillWithAll();

            using (var context = new MainContext(fakeContext.FakeOptions, fakeContext.FakeConfiguration().Object))
            {
                var repository = new GenericRepository <Product>(context);
                var service    = new GenericService <Product>(repository);

                var contextProduct = context.Products.Find(1);
                contextProduct.Quantity = 150;
                var response = service.Update(6, contextProduct);

                Assert.Equal("{ Message = Produto não encontrado. }", response.ToString());
            }
        }
Esempio n. 16
0
        public void Generic_GetById_Service(int id)
        {
            var fakeContext = new FakeContext("Generic_GetById_Service");

            fakeContext.FillWithAll();

            using (var context = new MainContext(fakeContext.FakeOptions, fakeContext.FakeConfiguration().Object))
            {
                var repository = new GenericRepository <Product>(context);
                var service    = new GenericService <Product>(repository);

                var contextProduct = context.Products.Find(id);
                var serviceProduct = service.GetById(id);

                Assert.IsType <Product>(serviceProduct);
                Assert.Equal(contextProduct, serviceProduct);
            }
        }
Esempio n. 17
0
        public static List <IcerikDto> Arama(string arama, int skip)
        {
            GenericService genericService = new GenericService();
            var            icerik         = (from m in genericService.Queryable <Menu>()
                                             join i in genericService.Queryable <Icerik.Icerikler>() on m.Id equals i.MenuId
                                             where i.Durum == Icerik.IcerikDurumEnum.Yayinlandi && i.Baslik.Contains(arama)
                                             orderby i.Id descending
                                             select new IcerikDto
            {
                Baslik = i.Baslik,
                Giris = i.Giris,
                Kategori = m.Isim,
                Tarih = i.YayinlanmaTarihi,
                Url = i.Url
            }).Skip(skip).Take(10).ToList();

            return(icerik);
        }
Esempio n. 18
0
        public ActionResult DeleteEmp(string id, string email)
        {
            EmployeeCVModel emp = new EmployeeCVModel();
            GenericService  act = new GenericService();

            emp.EmpID = id;
            emp.Email = email;
            SqlParameter[] parameters =
            {
                new SqlParameter("@EmpID",      SqlDbType.NVarChar, 12)
                {
                    Value = emp.EmpID ?? (object)DBNull.Value
                },
                new SqlParameter("@VLastName",  SqlDbType.NVarChar, 100)
                {
                    Value = emp.VLastName ?? (object)DBNull.Value
                },
                new SqlParameter("@VFirstName", SqlDbType.NVarChar, 100)
                {
                    Value = emp.VFirstName ?? (object)DBNull.Value
                },
                new SqlParameter("@NickName",   SqlDbType.NVarChar, 50)
                {
                    Value = emp.NickName ?? (object)DBNull.Value
                },
                new SqlParameter("@DOB",        SqlDbType.NVarChar, 50)
                {
                    Value = emp.DOB ?? (object)DBNull.Value
                },
                new SqlParameter("@Gender",     SqlDbType.NVarChar, 1)
                {
                    Value = emp.Gender ?? (object)DBNull.Value
                },
                new SqlParameter("@Email",      SqlDbType.NVarChar, 50)
                {
                    Value = emp.Email ?? (object)DBNull.Value
                },
                new SqlParameter("@ACTION",     "SelectByID")
            };
            DataSet ds = act.Generic("sp_InsertUpdateDelete_tblEmpCV", parameters);

            ViewBag.emp = ds.Tables[0];
            return(View());
        }
Esempio n. 19
0
        void SaveSettings()
        {
            LabelSetting settings;

            if ((settings = new GenericService <LabelSetting>().GetAll().FirstOrDefault()) == null)
            {
                new GenericService <LabelSetting>().Add(new LabelSetting
                {
                    BarcodeType  = cmbLabelType.Text,
                    BarHeight    = txtHeight.Text.ToInt(),
                    BorderType   = cmbBorderType.Text,
                    FontFamily   = cmbFont.Text,
                    FontSize     = txtSize.Text.ToInt(),
                    ForeColor    = cmbColor.Text,
                    LabelLenghth = txtLength.Text.ToInt(),
                    ListEnd      = txtEnd.Text.ToInt(),
                    ListStart    = txtStart.Text.ToInt(),
                    QtyToPrint   = txtQuantity.Text.ToInt(),
                    ShowBorder   = chkShowBorder.Checked,
                    ShowCheckSum = chkShowChecksum.Checked,
                    ShowTest     = chkShowText.Checked
                });
            }
            else
            {
                new GenericService <LabelSetting>().Update(new LabelSetting
                {
                    BarcodeType  = cmbLabelType.Text,
                    BarHeight    = txtHeight.Text.ToInt(),
                    BorderType   = cmbBorderType.Text,
                    FontFamily   = cmbFont.Text,
                    FontSize     = txtSize.Text.ToInt(),
                    ForeColor    = cmbColor.Text,
                    LabelLenghth = txtLength.Text.ToInt(),
                    ListEnd      = txtEnd.Text.ToInt(),
                    ListStart    = txtStart.Text.ToInt(),
                    QtyToPrint   = txtQuantity.Text.ToInt(),
                    ShowBorder   = chkShowBorder.Checked,
                    ShowCheckSum = chkShowChecksum.Checked,
                    ShowTest     = chkShowText.Checked,
                    id           = settings.id,
                }, l => l.id == settings.id);
            }
        }
Esempio n. 20
0
        public static DataTable getVarientProd(string style, string size, string color)
        {
            style = style == null ? "" : style.Trim();
            size  = size == null ? "" : size.Trim();
            color = color == null ? "" : color.Trim();
            DataTable             dt    = GenericService.getVewImageNewMasterDT();
            IEnumerable <DataRow> query =
                from dr in dt.AsEnumerable()
                where style.Equals(dr["StyleCode"] + "".Trim()) &&
                size.Equals(dr["Size"] + "".Trim())
                select dr;

            try
            {
                dt = query.CopyToDataTable <DataRow>();
            }
            catch { }
            return(dt);
        }
Esempio n. 21
0
        public async Task GetAllReturnEmpty()
        {
            // arrange
            var mapper = new Mock <IMapper>();
            var repo   = new Mock <IRepository <Patient> >();

            repo
            .Setup(x => x.GetAllAsync())
            .Returns(Task.FromResult(Enumerable.Empty <Patient>()));

            var service = new GenericService <Patient, PatientDto>(repo.Object, mapper.Object, new Mock <IUnitOfWork>().Object);

            // act
            var result = await service.GetAllAsync();

            // assert
            Assert.Empty(result);
            Assert.IsAssignableFrom <IEnumerable <PatientDto> >(result);
        }
Esempio n. 22
0
        public void Generic_Delete_Product_NotFound_Service_Warehouse()
        {
            var fakeContext = new FakeContext("Generic_Delete_Product_NotFound_Service_Warehouse");

            fakeContext.FillWith <Product>();

            using (var context = new MainContext(fakeContext.FakeOptions, fakeContext.FakeConfiguration().Object))
            {
                var repository = new GenericRepository <Product>(context);
                var service    = new GenericService <Product>(repository);

                var countBefore = service.GetAll().Count();

                Assert.Equal(5, countBefore);
                var response = service.Delete(6);
                Assert.Equal("{ Message = Produto não encontrado. }", response.ToString());
                Assert.Equal(5, service.GetAll().Count());
            }
        }
Esempio n. 23
0
        [Test] public void Get_WhenRepositoryThrowException_ShouldReturnError()
        {
            //Arrange
            Exception expectedException = new Exception(Guid.NewGuid().ToString());

            var repositoryMock = _mock.Mock <IGenericRepository <EventModel> >();

            repositoryMock
            .Setup(items => items.Get(null, null, ""))
            .Throws(expectedException);

            GenericService <EventModel> service = _mock.Create <GenericService <EventModel> >();

            //Act
            ResultService <IEnumerable <EventModel> > result = service.Get(null, null, "");

            //Assert
            AssertResultServiceException <IEnumerable <EventModel> >(result, expectedException);
        }
Esempio n. 24
0
        public void Generic_Update_Service(int id)
        {
            var fakeContext = new FakeContext("Generic_Update_Service");

            fakeContext.FillWithAll();

            using (var context = new MainContext(fakeContext.FakeOptions, fakeContext.FakeConfiguration().Object))
            {
                var repository = new GenericRepository <Product>(context);
                var service    = new GenericService <Product>(repository);

                var contextProduct = context.Products.Find(id);
                contextProduct.Quantity = 150;
                var response = service.Update(id, contextProduct);

                Assert.Equal("{ Message = Produto alterado com sucesso. }", response.ToString());
                Assert.Equal(150, service.GetById(id).Quantity);
            }
        }
Esempio n. 25
0
        public void Generic_Delete_Service()
        {
            var fakeContext = new FakeContext("Generic_Delete_Service");

            fakeContext.FillWithAll();

            using (var context = new MainContext(fakeContext.FakeOptions, fakeContext.FakeConfiguration().Object))
            {
                var repository = new GenericRepository <Product>(context);
                var service    = new GenericService <Product>(repository);

                var countBefore = service.GetAll().Count();

                Assert.Equal(5, countBefore);
                var response = service.Delete(1);
                Assert.Equal("{ Message = Produto removido com sucesso. }", response.ToString());
                Assert.Equal(4, service.GetAll().Count());
            }
        }
        public void ShouldGetOneItemWithFindByIdMethod()
        {
            Mock <IGenericRepository <ExamProgram> > examProgramRepositoryMock = new Mock <IGenericRepository <ExamProgram> >();
            Mock <IActivityLoggerService>            activityLoggerMock        = new Mock <IActivityLoggerService>();

            examProgramRepositoryMock.Setup((e) => e.FindById("10", null)).Returns(new ExamProgram()
            {
                Id        = 10,
                EndDate   = System.DateTime.Now.AddYears(1),
                StartDate = System.DateTime.Now,
                Courses   = new List <Course>()
            });

            IGenericService <ExamProgram> ExamProgramService = new GenericService <ExamProgram>(examProgramRepositoryMock.Object, activityLoggerMock.Object);

            ExamProgram result = ExamProgramService.FindById("10");

            Assert.NotNull(result);
            Assert.Equal(10, result.Id);
        }
Esempio n. 27
0
        public static DataTable getRelProductDT(string pType)
        {
            DataTable             dt    = GenericService.getVewImageNewMasterDT();
            IEnumerable <DataRow> query =
                from dr in dt.AsEnumerable()
                where dr.Field <String>("SKUProductType") == pType &&
                dr.Field <String>("StyleCode") == String.Empty
                select dr;

            try
            {
                dt = query.CopyToDataTable <DataRow>();
            }
            catch (InvalidOperationException e)
            {
                Logger.Error("Exception occur CatService.getRelProductDT()", e);
                dt = new DataTable();
            }
            return(dt);
        }
Esempio n. 28
0
        public void TestCacheWithGenericClass()
        {
            Assert.AreEqual(0, cache3.Hits);
            Assert.AreEqual(0, cache3.Misses);

            var result1 = new GenericService <int>().MethodToCache1("5");

            Assert.AreEqual(0, cache3.Hits);
            Assert.AreEqual(2, cache3.Misses);

            var result2 = new GenericService <int>().MethodToCache1("5");

            Assert.AreEqual(1, cache3.Hits);
            Assert.AreEqual(2, cache3.Misses);

            var result3 = new GenericService <byte>().MethodToCache1("5");

            Assert.AreEqual(1, cache3.Hits);
            Assert.AreEqual(4, cache3.Misses);
        }
Esempio n. 29
0
        public void TestCacheWithGenericClassAndGenericKey()
        {
            Assert.AreEqual(0, cache3.Hits);
            Assert.AreEqual(0, cache3.Misses);

            var result1 = new GenericService <int>().MethodToCache2 <string>("5");

            Assert.AreEqual(0, cache3.Hits);
            Assert.AreEqual(2, cache3.Misses);

            var result2 = new GenericService <int>().MethodToCache2 <string>("5");

            Assert.AreEqual(1, cache3.Hits);
            Assert.AreEqual(2, cache3.Misses);

            var result3 = new GenericService <int>().MethodToCache2 <int>(5);

            Assert.AreEqual(1, cache3.Hits);
            Assert.AreEqual(4, cache3.Misses);
        }
Esempio n. 30
0
        public static DataTable getDTBySKUORStyle(string skuCode, string style)
        {
            DataTable             dt    = GenericService.getVewImageNewMasterDT();
            IEnumerable <DataRow> query =
                from dr in dt.AsEnumerable()
                where dr.Field <String>("SKUCode") == skuCode ||
                dr.Field <String>("StyleCode") == style
                select dr;

            try
            {
                dt = query.CopyToDataTable <DataRow>();
            }
            catch (InvalidOperationException e)
            {
                Logger.Error("Exception occur CategoryDetailsService.getDTBySKUORStyle() ", e);
                return(null);
            }
            return(dt);
        }
Esempio n. 31
0
        public void Test_Create_SaleOutputMessage_Sale(int id)
        {
            var msg         = new MessageFactory();
            var fakeContext = new FakeContext("Create_SaleOutputMessage_Sale");

            fakeContext.FillWithAll();

            using (var context = new MainContext(fakeContext.FakeOptions, fakeContext.FakeConfiguration().Object))
            {
                var repository = new GenericRepository <Sale>(context);
                var service    = new GenericService <Sale>(repository);

                var sale = service.GetById(id);

                var response = msg.Create(MessageType.SaleCreated, sale);

                Assert.IsType <SaleOutputMessage>(response);
                Assert.Equal("SaleCreated", response.MessageTitle);
            }
        }
 public void Initialize()
 {
     webLogs = new GenericRepository<WebLog>(new WebLogMockRepositoryContext());
     webLogService = new GenericService<WebLog>(webLogs);
 }
 public WebLogController(GenericService<User> userService, GenericService<WebLog> webLogService)
 {
     this.userService = userService;
     this.webLogService = webLogService;
 }
 public ScorecardColumnPath(StratsysAuthentication authentication, string id)
 {
     m_service = new GenericService(authentication, Path.ScorecardColumn(id).ResponsibilityRoles);
     m_service2 = new GenericService(authentication, Path.ScorecardColumn(id).Descriptionfields);
 }
		public SubscriberWithGenericDependency(GenericService<string> genericService)
		{
			_genericService = genericService;
		}
Esempio n. 36
0
 public PeopleController(GenericService genericService)
 {
     _genericService = genericService;
 }
        public void SetUp()
        {
            // will be used in GetById and GetAll mocks
            var entities = new List<Product>();
            for (int i = 0; i < 100; i++)
                entities.Add(new Product { Id = i, Name = "Product" });

            // setup a fake repository for productService .. retrieves data from the above list.
            var mockProductRepo = new Mock<IRepository<Product>>();
            mockProductRepo
                .Setup(e => e.Add(It.IsAny<Product>()))
                .Callback(() => { productRepoCalls["Add"] += 1; })
                .Returns((Product entity) =>
                {
                    entity.Id = 1; // give this an ID so it registers as 'non transient'
                    return entity;
                });
            mockProductRepo
                .Setup(e => e.Update(It.IsAny<Product>()))
                .Callback(() => { productRepoCalls["Update"] += 1; })
                .Returns((Product entity) => { return entity; });
            mockProductRepo
                .Setup(e => e.Delete(It.IsAny<Product>()))
                .Callback(() => { productRepoCalls["Delete"] += 1; });
            mockProductRepo
                .Setup(e => e.GetById(It.IsAny<int>()))
                .Callback(() => { productRepoCalls["GetById"] += 1; })
                .Returns((int id) =>
                {
                    return entities.Find(e => e.Id == id);
                });
            mockProductRepo
                .Setup(e => e.GetAll())
                .Callback(() => { productRepoCalls["GetList"] += 1; })
                .Returns(entities);

            // we want our service to call all of it's real methods
            // they're all marked as virtual so we have to explicitally tell moq to call them.
            var mockProductService = new Mock<GenericService<Product>>(mockProductRepo.Object);
            mockProductService.Setup(e => e.New()).CallBase();

            mockProductService.Setup(e => e.Add(It.IsAny<Product>())).CallBase();
            mockProductService.Setup(e => e.Update(It.IsAny<Product>())).CallBase();
            // mockProductService.Setup(e => e.Delete(It.IsAny<Product>()));

            mockProductService.Setup(e => e.ValidateAdd(It.IsAny<Product>())).CallBase();
            mockProductService.Setup(e => e.ValidateUpdate(It.IsAny<Product>())).CallBase();
            mockProductService.Setup(e => e.ValidateDelete(It.IsAny<Product>())).CallBase();

            mockProductService.Setup(e => e.GetById(It.IsAny<int>())).CallBase();
            mockProductService.Setup(e => e.GetList()).CallBase();
            mockProductService.Setup(e => e.GetList(It.IsAny<int>(), It.IsAny<int>())).CallBase();

            productService = mockProductService.Object;
        }
 public void Pagesize_10_and_pageindex_1_must_return_7_rows()
 {
     var service = new GenericService<WebLog>(new GenericRepository<WebLog>(new WebLogMockRepositoryContext()));
     Int32 itemCount;
     var result = service.Select(null, null, null, null, null, out itemCount);
 }
Esempio n. 39
0
 public void MyTestInitialize()
 {
     var secrets = Secrets.stripe.Split('\t');
     var serializer = new JsonSerializer();
     _service = new GenericService<StripeClient>("https://api.stripe.com/v1/", secrets[0], secrets[1], serializer);
 }
        public void All_null_parameters_brings_all_values()
        {
            var service = new GenericService<WebLog>(new GenericRepository<WebLog>(new WebLogMockRepositoryContext()));
            Int32 itemCount;
            var result = service.Select(null, null, null, null, null, out itemCount);

            Assert.AreEqual(itemCount, result.Count);
            Assert.AreEqual(itemCount, webLogs.ToList().Count);
        }