Beispiel #1
0
        public void TestGetAllRegionOK()
        {
            ContextObl           context    = ContextFactory.GetMemoryContext(Guid.NewGuid().ToString());
            IRepository <Region> regionRepo = new BaseRepository <Region>(context);

            Region regionToAdd = new Region()
            {
                Id   = Guid.NewGuid(),
                Name = Region.RegionName.Región_Centro_Sur
            };

            Region regionToAdd2 = new Region()
            {
                Id   = Guid.NewGuid(),
                Name = Region.RegionName.Región_Este
            };

            regionRepo.Add(regionToAdd);
            regionRepo.Add(regionToAdd2);

            List <Region> listTest = new List <Region>();

            listTest.Add(regionToAdd);
            listTest.Add(regionToAdd2);

            List <Region> listOfCategories = regionRepo.GetAll().ToList();

            CollectionAssert.AreEqual(listTest, listOfCategories);
        }
        public void TestGetAllLodgingsOK()
        {
            ContextObl            context           = ContextFactory.GetMemoryContext(Guid.NewGuid().ToString());
            IRepository <Reserve> reserveRepository = new BaseRepository <Reserve>(context);

            Reserve reserveForAFamily = new Reserve()
            {
                Id                   = Guid.NewGuid(),
                Name                 = "Martin",
                LastName             = "Gutman",
                Email                = "*****@*****.**",
                PhoneNumberOfContact = 24006478,
                DescriptionForGuest  = "Un lugar para pasar el rato con la familia, ideal para tomar un relax",
                LodgingOfReserve     = lodging,
                CheckIn              = new DateTime(2020, 10, 25),
                CheckOut             = new DateTime(2020, 12, 10),
                QuantityOfAdult      = 2,
                QuantityOfChild      = 0,
                QuantityOfBaby       = 1,
                StateOfReserve       = Reserve.ReserveState.Creada
            };

            reserveRepository.Add(reserve);
            reserveRepository.Add(reserveForAFamily);

            List <Reserve> listWithOriginalsReserves = new List <Reserve>();

            listWithOriginalsReserves.Add(reserve);
            listWithOriginalsReserves.Add(reserveForAFamily);

            List <Reserve> listOfReserveOfDb = reserveRepository.GetAll().ToList();

            CollectionAssert.AreEqual(listWithOriginalsReserves, listOfReserveOfDb);
        }
        static void Main(string[] args)
        {
            IRepository <Student> rep  = new BaseRepository <Student>(s_students);
            IRepository <Class>   rep1 = new BaseRepository <Class>(s_classes);



            rep1.Add(new Class("18DTHQA1"));
            rep1.Add(new Class("18DTHQA2"));

            rep.Add(new Student("AAA", 11));
            rep.Add(new Student("BBB", 22));
            rep.Add(new Student("CCC", 33));
            rep.Add(new Student("DDD", 44));

            Console.WriteLine("List all classes:");


            foreach (var cl in rep1.GetAll())
            {
                Console.WriteLine(cl.Name);
            }
            Console.WriteLine("List all Students:");
            foreach (var st in rep.GetAll())
            {
                Console.WriteLine(st.Name);
            }
        }
        public async Task Update_Success()
        {
            var course = new Course
            {
                CourseId    = 1,
                Name        = "Toeic 500",
                Description = "Khóa học ôn thi dành cho người mất gốc",
                TimeStudy   = "3 month"
            };

            await _courseRepository.Add(course);

            var courseUpdate = new CourseRequest
            {
                Name        = "Toeic 700",
                Description = "Khóa học ôn thi dành cho người mất gốc",
                TimeStudy   = "3 month"
            };

            var courseService = new CourseService(_courseRepository);

            var controller = new CourseController(courseService);

            //action
            var result = await controller.UpdateCourse(1, courseUpdate);

            //course

            result.Should().NotBeNull();

            var response    = Assert.IsType <OkObjectResult>(result.Result);
            var returnValue = Assert.IsType <Course>(response.Value);

            Assert.Equal("Toeic 700", returnValue.Name);
        }
Beispiel #5
0
        public DLModel.RFAReferralFile addReferralFileIntake(string filename, int userid)
        {
            int rfaReferralID = AddReferral();

            return(_rfaReferralFileRepo.Add(new DLModel.RFAReferralFile {
                RFAReferralFileName = rfaReferralID + "_" + filename, RFAFileTypeID = GlobalConst.FileTypes.IntakeUpload, RFAReferralID = rfaReferralID, RFAFileUserID = userid, RFAFileCreationDate = System.DateTime.Now
            }));
        }
Beispiel #6
0
 public bool Add(T model)
 {
     model.Id         = Guid.NewGuid().ToString();
     model.CreatedBy  = "Admin";
     model.Created    = System.DateTime.Now;
     model.Modified   = System.DateTime.Now;
     model.ModifiedBy = "Admin";
     return(repository.Add(model));
 }
Beispiel #7
0
 public int addClientManagedCareCompany(ClientManagedCareCompany _clientManagedCareCompany)
 {
     if (_clientMMCRepo.GetAll(mmc => mmc.ClientID == _clientManagedCareCompany.ClientID).Count() > 0)
     {
         return(0);
     }
     else
     {
         return(_clientMMCRepo.Add(_clientManagedCareCompany).ClientCompanyID);
     }
 }
        public virtual bool Add(T entity)
        {
            if (string.IsNullOrWhiteSpace(entity.Id))
            {
                entity.Id = Guid.NewGuid().ToString();
            }
            var add  = Repository.Add(entity);
            var save = Repository.Save();

            return(save);
        }
        public void AddOk2()
        {
            T FirstEntity  = CreateEntity();
            T SecondEntity = CreateEntity();
            BaseRepository <T, X> baseRepo = CreateRepository();

            baseRepo.Add(FirstEntity);
            baseRepo.Add(SecondEntity);
            baseRepo.Save();

            Assert.AreEqual(2, baseRepo.GetAll().ToList().Count());
        }
 public ServerResponse <string, string, CommunityMemberVm> AddMember(CommunityMember cMemb)
 {
     try
     {
         baseRepo.Add <CommunityMember>(cMemb);
         CommunityMemberVm cmvm = new CommunityMemberVm(cMemb, false);
         return(new ServerResponse <string, string, CommunityMemberVm>(ErrorMessages.SuccessString, null, cmvm));
     }
     catch (Exception e)
     {
         return(new ServerResponse <string, string, CommunityMemberVm>(ErrorMessages.ErrorString, ErrorMessages.ErrMsg_Generic, null));
     }
 }
        public void SaveOk2()
        {
            BaseRepository <T, X> baseRepo = CreateRepository();
            T InitEntity  = CreateEntity();
            T InitEntity2 = CreateEntity();

            baseRepo.Add(InitEntity);
            baseRepo.Add(InitEntity2);
            baseRepo.Save();

            T RetrievedEntity = GetSavedEntity(baseRepo, InitEntity2);

            Assert.AreEqual(InitEntity2, RetrievedEntity);
        }
Beispiel #12
0
        public async Task CloneSignatureRequests(ApplicationUser user, ApplicationUser warrantUser)
        {
            var requestsForUser = _signatureRequestRepository.FindBy(x => x.ApplicationUserId == user.Id);

            foreach (var request in requestsForUser)
            {
                await _signatureRequestRepository.Add(new IncomingSignatureRequest
                {
                    ApplicationUserId   = warrantUser.Id,
                    DocumentId          = request.DocumentId,
                    UserRequester       = request.UserRequester,
                    ClonnedUsingWarrant = true
                });
            }
        }
Beispiel #13
0
        public void InsertNewOtel(OtelDto otel)
        {
            Otel otelBilgiler = new Otel()
            {
                Name        = otel.Name,
                Description = otel.Description,
                Email       = otel.Email,
                Restaurant  = otel.Restaurant,
                Address     = otel.Address,
                Bar         = otel.Bar,
                Breakfast   = otel.Breakfast,
                CarPark     = otel.CarPark,
                Cover       = otel.Cover,
                Gym         = otel.Gym,
                Pool        = otel.Pool,
                RoomService = otel.RoomService,
                Spa         = otel.Spa,
                Star        = otel.Star,
                Tel         = otel.Tel,
                Status      = otel.Status,
                Wifi        = otel.Wifi
            };

            using (BaseRepository <Otel> _repo = new BaseRepository <Otel>())
            {
                _repo.Add(otelBilgiler);
            }
        }
Beispiel #14
0
        public void CreateMenu(int id)
        {
            using (BaseRepository <Menu> _repo = new BaseRepository <Menu>())
            {
                if (_repo.Query <Menu>().Where(p => (p.PageId == id) && (p.IsDeleted == false)).ToList().Any() == false)
                {
                    var Page1 = _repo.Query <Page>().Where(p => p.Id == id).First();
                    if (_repo.Query <Menu>().Where(x => x.PageId == Page1.Id).Any())
                    {
                        var remove = _repo.Query <Menu>().Where(x => x.PageId == Page1.Id).ToList();
                        foreach (var item in remove)
                        {
                            _repo.Delete(item);
                        }
                    }

                    Menu menu = new Menu()
                    {
                        IsDeleted = false,
                        PageId    = id,
                        Page      = Page1,
                        MenuName  = Page1.PageName
                    };
                    _repo.Add(menu);
                }
            }
        }
Beispiel #15
0
        public async Task <AccountRegistrationResponse> RegisterUserAsync(AccountRegistrationRequest request)
        {
            var existsUser = await GetUserByPhoneAsync(request.Phone);

            if (existsUser?.CreateUserPlace == CreateUserPlace.FromRegistration)
            {
                return(new AccountRegistrationResponse()
                {
                    Code = ResponseCode.UserWithTheSamePhoneExists
                });
            }

            var user = _userEntityFactory.Create(
                request.Name,
                request.LastName,
                request.Phone,
                request.Password,
                CreateUserPlace.FromRegistration);

            _userRepository.Add(user);
            await _userRepository.SaveChangesAsync();

            return(new AccountRegistrationResponse()
            {
                User = _mapper.Map <UserModel>(user)
            });
        }
Beispiel #16
0
        public int AddBook(BookInfo BookInfo)
        {
            var book = new BookEntity()
            {
                Author         = BookInfo.Author,
                Category       = BookInfo.Category,
                Count          = BookInfo.Count,
                CreateDate     = BookInfo.CreateDate,
                CreateUser     = BookInfo.CreateUser,
                LastModifyDate = BookInfo.LastModifyDate,
                LastModifyUser = BookInfo.LastModifyUser,
                Name           = BookInfo.Name,
                Note           = BookInfo.Note,
                Number         = BookInfo.Number,
                Press          = BookInfo.Press,
                Price          = BookInfo.Price,
                Style          = BookInfo.Style,
                Type           = BookInfo.Type,
                Year           = BookInfo.Year
            };

            book.CreateDate = DateTime.Now;
            _DBBook.Add(book);

            _DBBookItem.Add(new BookItemEntity()
            {
                BookID  = book.ID,
                Status  = (int)BookStatus.正常,
                BarCode = BookInfo.BarCode
            });

            return(book.ID);
        }
Beispiel #17
0
        public ObjectResult Post(string nome, string cpf, string endereco)
        {
            var cliente = new Cliente(nome, cpf, endereco);

            cliente = _clienteRepository.Add(cliente);
            return(Ok(cliente));
        }
Beispiel #18
0
        protected override int Process(IEnumerable <IBaseEntity> datas, dynamic sender = null)
        {
            var _name = CompanySpider.CurrentCompany;

            Logger.Log(LogLevel.Information, 1, this, null,
                       (a, b) =>
            {
                return($"[管道]等待{CompanySpider.SleepValue}秒处理下条数据");
            });
            Thread.Sleep(1000 * CompanySpider.SleepValue);
            foreach (var data in datas)
            {
                var _entity = data as CompanyEntity;
                _entity.Seed = _name;
                try
                {
                    var result = Repository.Add(_entity).Result;
                    Logger.Log(LogLevel.Information, 1, this, null,
                               (a, b) =>
                    {
                        return($"[管道][{result}-{_entity.Seed}]: {_entity.ToString()}");
                    });
                }
                catch (Exception ex)
                {
                    Logger.Log(LogLevel.Error, 1, this, null,
                               (obj, e) =>
                    {
                        return($"[管道][{_entity.Seed}]异常:{_entity.ToString()}  {ex.Message}");
                    });
                }
            }

            return(datas.Count());
        }
Beispiel #19
0
        public async Task <ActionResult <Discount> > PostDiscount(Discount discount)
        {
            _repository.Add(discount);
            await _repository.SaveChangesAsync();

            return(CreatedAtAction("GetDiscount", new { id = discount.Id }, discount));
        }
Beispiel #20
0
 public bool Register(User user)
 {
     using (BaseRepository <User> _repo = new BaseRepository <User>())
     {
         if (user.Username != null && user.Password != null && user.Name != null)
         {
             var result = _repo.Query <User>().Where(x => (x.Username == user.Username) && (x.Password == user.Password)).Any();
             if (!result)
             {
                 User newuser = new User()
                 {
                     CreateTime = DateTime.Now,
                     IsDeleted  = false,
                     Name       = user.Name,
                     Username   = user.Username,
                     Password   = user.Password,
                     yetki      = 1
                 };
                 _repo.Add(newuser);
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
         else
         {
             return(false);
         }
     }
 }
        public void GetReviewByReserveIdTest()
        {
            ContextObl             context         = ContextFactory.GetMemoryContext(Guid.NewGuid().ToString());
            IReviewRepository      reviewRepo      = new ReviewRepository(context);
            ITouristSpotRepository touristSpotRepo = new TouristSpotRepository(context);
            ILodgingRepository     lodgingRepo     = new LodgingRepository(context);

            IRepository <Reserve> reserveRepo = new BaseRepository <Reserve>(context);

            touristSpotRepo.Add(touristSpot);
            lodgingRepo.Add(lodging);
            reserveRepo.Add(reserve);

            Review reviewToAdd = new Review()
            {
                Id                    = Guid.NewGuid(),
                Description           = "Me gusto mucho la estadia",
                IdOfReserve           = reserve.Id,
                LastNameOfWhoComments = reserve.LastName,
                NameOfWhoComments     = reserve.Name,
                LodgingOfReview       = lodging,
                Score                 = 4
            };

            reviewRepo.Add(reviewToAdd);
            Review reviewResult = reviewRepo.GetReviewByReserveId(reserve.Id);

            Assert.IsTrue(reviewResult.Equals(reviewToAdd));
        }
Beispiel #22
0
        public string addRFAReferralInvoice(RFAReferralInvoice _rRFAReferralInvoice)
        {
            MMCDbContext _MMCDbContext             = new MMCDbContext();
            string       getIncrementInvoiceNumber = "";
            var          billingDetails            = getInvoiceNumberByClientID(_rRFAReferralInvoice.ClientID.Value);

            if (billingDetails == null)
            {
                var _getInvoiceNumber = (from _clientBill in _MMCDbContext.clientBillings
                                         join _client in _MMCDbContext.clients
                                         on _clientBill.ClientID equals _client.ClientID
                                         join _patClaim in _MMCDbContext.patientClaims
                                         on _client.ClientID equals _patClaim.PatClientID
                                         where _patClaim.PatientClaimID == _rRFAReferralInvoice.PatientClaimID
                                         select new
                {
                    _clientBill.ClientInvoiceNumber
                }).FirstOrDefault();
                getIncrementInvoiceNumber = _getInvoiceNumber.ClientInvoiceNumber.ToString();
            }
            else
            {
                getIncrementInvoiceNumber = IncrementInvoice(billingDetails.InvoiceNumber);
            }

            _rRFAReferralInvoice.InvoiceNumber = getIncrementInvoiceNumber;
            return(_rFAReferralInvoiceRepo.Add(_rRFAReferralInvoice).InvoiceNumber);
        }
Beispiel #23
0
        public int addClientStatement(ClientStatement _clientStatement)
        {
            MMCDbContext _MMCDbContext = new MMCDbContext();
            string       getIncrementStatementNumber = "";
            var          statementDetails            = getStatementNumberByClient(_clientStatement.ClientID);

            if (statementDetails == null)
            {
                var _getStatementNumber = (from _clientPrivateLabel in _MMCDbContext.clientPrivateLabelss
                                           where _clientStatement.ClientID == _clientPrivateLabel.ClientID
                                           select new
                {
                    _clientPrivateLabel.ClientStatementStart
                }).FirstOrDefault();
                getIncrementStatementNumber = _getStatementNumber.ClientStatementStart.ToString();
            }
            else
            {
                getIncrementStatementNumber = IncrementInvoice(statementDetails.ClientStatementNumber);
            }

            _clientStatement.ClientStatementNumber   = getIncrementStatementNumber;
            _clientStatement.ClientStatementFileName = _clientStatement.ClientStatementNumber + "_" + GlobalConst.FileName.InvoiceStatement + GlobalConst.Extension.pdf;
            return(_clientStatementRepo.Add(_clientStatement).ClientStatementID);
        }
Beispiel #24
0
        public void TestBaseRepository()
        {
            var repository = new BaseRepository <User>();
            var account    = "user_" + DateTime.Now.ToString("yyyy_MM_dd HH:mm:ss");

            repository.Add(new User
            {
                Account  = account,
                Name     = account,
                Password = "******"
                ,
                Id = account
            });

            var user = repository.FindSingle(u => u.Id == account);

            Assert.NotNull(user);

            account      = "newuser_" + DateTime.Now.ToString("yyyy_MM_dd HH:mm:ss");
            user.Account = account;
            repository.Update(user);

            var newuser = repository.FindSingle(u => u.Id == account);

            Assert.AreEqual(newuser.Account, account);

            repository.Update(u => u.Account == account, u => new User {
                Name = account
            });
            newuser = repository.FindSingle(u => u.Account == account);
            Assert.AreEqual(newuser.Name, account);
        }
Beispiel #25
0
 public void InsertNewLayout(Array Liste, string name)
 {
     using (BaseRepository <PageLayout> _repo = new BaseRepository <PageLayout>())
     {
         if (_repo.Query <PageLayout>().Where(p => p.Name == name).Any())
         {
         }
         else
         {
             PageLayout pl = new PageLayout();
             pl.Name = name;
             _repo.Add(pl);
             using (BaseRepository <PLItem> _repo1 = new BaseRepository <PLItem>())
             {
                 int i = 1;
                 foreach (var item in Liste)
                 {
                     PLItem pi = new PLItem();
                     pi.CreateTime   = DateTime.Now;
                     pi.PageLayoutId = pl.Id;
                     pi.SizeValue    = item.ToString();
                     pi.Order        = i;
                     i++;
                     _repo1.Add(pi);
                 }
             }
         }
     }
 }
Beispiel #26
0
        private void btnSaloonSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (tbxSaloonName.Text == "")
                {
                    MessageBox.Show("Please do not leave blank !");
                }
                else
                {
                    Saloon saloon = new Saloon()
                    {
                        Saloons  = tbxSaloonName.Text,
                        Capacity = Convert.ToInt32(nudSaloonCapacity.Value)
                    };
                    saloons.Add(saloon);

                    MessageBox.Show("Saloon successfully added :)");
                }
            }
            catch (Exception x)
            {
                MessageBox.Show(x.ToString());
            }
        }
        public void InsertNewLayout(string Name, List <string> Kolonlar)
        {
            Layout layout = new Layout();

            using (BaseRepository <Layout> _repo = new BaseRepository <Layout>())
            {
                Layout pl = new Layout
                {
                    Name      = Name,
                    CreatedAt = DateTime.Now,
                    IsDeleted = false
                };
                _repo.Add(pl);
            }

            using (BaseRepository <LayoutItem> _repo = new BaseRepository <LayoutItem>())
            {
                layout = _repo.SetContext <Layout>().Where(c => c.Name == Name).First();


                foreach (var kolonBilgisi in Kolonlar)
                {
                    var post = new LayoutItem {
                        Class = kolonBilgisi.ToString(), LayoutId = layout.Id,
                    };
                    _repo.Add(post);
                }
            }
        }
Beispiel #28
0
        public async Task <ActionResult <Customer> > PostCustomer(Customer customer)
        {
            _repository.Add(customer);
            await _repository.SaveChangesAsync();

            return(CreatedAtAction("GetCustomer", new { id = customer.Id }, customer));
        }
        public bool AddContactUsRequest(ContactUsRequest request)
        {
            request.RequestDate = DateTime.UtcNow;
            _repo.Add(request);

            return(_repo.SaveChanges());
        }
        public virtual bool Add(T entity)
        {
            var add  = Repository.Add(entity);
            var save = Repository.Save();

            return(save);
        }
 public void loadCsvDataIntoDb()
 {
     List<MainObjectFromCsvFileInfo> csvDataList = readCsvFile();
     var baseRepo = new BaseRepository();
     foreach (var mainObject in csvDataList)
     {
         var communityMemberObject = convertMainObjectToCommunityMember(mainObject);
         var children = communityMemberObject.Children;
         communityMemberObject.Children = null;
         baseRepo.Add<CommunityMember>(communityMemberObject);
         if (children != null && children.Count() > 0)
         {
             foreach (var child in children)
             {
                 child.CommunityMemberId = communityMemberObject.CommunityMemberId;
                 baseRepo.Add<Child>(child);
             }
         }
     }
 }