예제 #1
0
        public void messclient(string idsignlr, string idurl, string name, string message, string ip, string emailAgent, string idagent)
        {
            var ID_Visitor = ip; if (_ChatVisitor.GetById(ID_Visitor) == null)

            {
                _ChatVisitor.Add(new Visitor {
                    ID = ID_Visitor, User_name = name
                }); _LineChat.Add(new ChatLine {
                    Actor = true, Date = DateTime.Now, Line = message, Agent = string.IsNullOrEmpty(idagent) ? null : idagent, Visitor = ID_Visitor, ID_Customer = idurl
                });
            }
            else
            {
                _LineChat.Add(new ChatLine {
                    Actor = true, Date = DateTime.Now, Line = message, Agent = string.IsNullOrEmpty(idagent) ? null : idagent, Visitor = ID_Visitor, ID_Customer = idurl
                });
            }
            IEnumerable <chatagent2> listagent = new List <chatagent2>(); if (string.IsNullOrEmpty(emailAgent))

            {
                listagent = _Chatagent.GetAll().Where(x => x.idchat == idurl);
            }
            else
            {
                listagent = _Chatagent.GetAll().Where(x => x.idchat == idurl && x.email == emailAgent); if (listagent.Count() == 0)
                {
                    listagent = _Chatagent.GetAll().Where(x => x.idchat == idurl);
                }
            }
            foreach (var agents in listagent)
            {
                Clients.Client(agents.urlchat).broadcastMessage(idsignlr, name, message);
            }
        }
예제 #2
0
        public virtual void Add(T entity, bool save = true)
        {
            try
            {
                UpdateData(entity);

                if (entity.Id == 0)
                {
                    _repo.Add(entity);
                }
                else
                {
                    _repo.Update(entity);
                }


                if (save)
                {
                    _uow.SaveChanges();
                }
            }
            catch (Exception ex)
            {
            }
        }
예제 #3
0
        private void LoadDepartments()
        {
            var giovisDepartment = new Department("dep001", 1, "Giovanny Kaviedes");
            var damiDepartment   = new Department("dep002", 1, "Dami Dami");
            var figueHole        = new Department("dep003", 1, "Cojito Figuemora");

            using (var context = new ApplicationContext(_options))
            {
                var repository = new RepositoryBase <Department>(context);
                repository.Add(giovisDepartment);
                repository.Add(damiDepartment);
                repository.Add(figueHole);
            }
        }
예제 #4
0
        public ActionResult OrderCheck()
        {
            var sepet  = Session["cart"] as MyCart;
            int UserID = userRepository.SelectAll().Where(x => x.UserName == User.Identity.Name).FirstOrDefault().ID;

            Order yeniSiparis = new Order();

            yeniSiparis.UserDetailID = UserID;
            yeniSiparis.ShipAddress  = "Kadıköy";
            yeniSiparis.Email        = "*****@*****.**";
            yeniSiparis.Phone        = "123456789";
            yeniSiparis.OrderDetails = new List <OrderDetail>();
            foreach (CartItem item in sepet.Sepet)
            {
                OrderDetail yeniSiparisDetayi = new OrderDetail();
                yeniSiparisDetayi.Discount = 0;
                yeniSiparisDetayi.AlbumID  = item.ID;
                yeniSiparisDetayi.Price    = item.Price;
                yeniSiparisDetayi.Quantity = item.Quantity;

                yeniSiparis.OrderDetails.Add(yeniSiparisDetayi);
            }
            orderRepository.Add(yeniSiparis);
            Session["cart"] = new MyCart();
            return(View());
        }
예제 #5
0
        protected C With <T, S, Tid>(
            RepositoryBase <T> repository,
            string name,
            string template       = null,
            Action <S> configurer = null)

            where T : IEntity
            where S : EntitySetupBase <T, Tid>
            where Tid : IEquatable <Tid>
        {
            var item = ObjectFactory.CreateInstance <T>();

            TemplateManager.ApplyTemplate(item, template);
            Func <T, Tid> creator = (i) =>
            {
                DataCreatorFactory.GetCreator <T>().Create(i);
                return(Activator.CreateInstance <S>().GetId(i));
            };
            var itemSetup = (S)Activator.CreateInstance(typeof(S)) as S;

            itemSetup.Initialize(item, creator, this);
            configurer?.Invoke(itemSetup);
            repository.Add(name, itemSetup.Final);
            return((C)this);
        }
예제 #6
0
        public void SetIKnowWord(Guid wordID, int userID)
        {
            RepositoryBase <EWSKnownWords> _rep          = new RepositoryBase <EWSKnownWords>();
            RepositoryBase <EWSWillLearn>  _repLearnList = new RepositoryBase <EWSWillLearn>();


            //sorgula yoksa ekle.
            EWSKnownWords knownWord = _rep.Get(p => p.WordUN == wordID && p.UserID == userID);

            //varsa öğreneceklerim listesinden çıkar
            EWSWillLearn learnList = _repLearnList.Get(p => p.WordUN == wordID && p.UserID == userID);

            if (learnList != null)
            {
                _repLearnList.Remove(learnList);
            }

            if (knownWord != null)
            {
                return;
            }

            EWSKnownWords listKnow = new EWSKnownWords()
            {
                UN     = Guid.NewGuid(),
                UserID = userID,
                WordUN = wordID
            };

            _rep.Add(listKnow);
        }
예제 #7
0
        public void SetILearn(Guid wordID, int userID)
        {
            RepositoryBase <EWSWillLearn>  _rep      = new RepositoryBase <EWSWillLearn>();
            RepositoryBase <EWSKnownWords> _repKnown = new RepositoryBase <EWSKnownWords>();

            //varsa bildiklerim listesinden çıkar
            EWSKnownWords learnList = _repKnown.Get(p => p.WordUN == wordID && p.UserID == userID);

            if (learnList != null)
            {
                _repKnown.Remove(learnList);
            }

            //sorgula yoksa ekle.
            EWSWillLearn willLearnWord = _rep.Get(p => p.WordUN == wordID && p.UserID == userID);

            if (willLearnWord != null)
            {
                return;
            }

            EWSWillLearn listLearn = new EWSWillLearn()
            {
                UN     = Guid.NewGuid(),
                UserID = userID,
                WordUN = wordID
            };

            _rep.Add(listLearn);
        }
예제 #8
0
        public void OgrenilecekListeCikar(EWSLearnList ewsLearnList)
        {
            IRepositoryBase <EWSLearnList> _rep = new RepositoryBase <EWSLearnList>();

            ewsLearnList = _rep.Get(p => p.ListUN == ewsLearnList.ListUN && p.UserID == ewsLearnList.UserID);
            _rep.Add(ewsLearnList);
        }
예제 #9
0
 private void Save()
 {
     if (!ValidData())
     {
         string msg = null;
         foreach (RuleViolation viol in RulesViolations)
         {
             msg += viol.ErrorMessage;
         }
         RulesViolations.Clear();
         Helper.ShowMessage(msg);
         return;
     }
     try
     {
         WriteModelValues(_currnetModel);
         if (_modelState == ModelState.New)
         {
             _repository.Add(_currnetModel);
         }
         _unitOfWork.Save();
         SetState(ModelState.Saved);
     }
     catch (Exception ex)
     {
         Helper.LogAndShow(ex);
     }
 }
예제 #10
0
        void Save()
        {
            var tempPaymentOrders = new List <PaymentInstruction>();

            foreach (var cpOrder in CurrentPaymentOrders)
            {
                tempPaymentOrders.Add(cpOrder);
            }
            foreach (var olOrders in OldLoansOrders)
            {
                tempPaymentOrders.Add(olOrders);
            }

            if (_modelState == ModelState.New)
            {
                foreach (var tpOrders in tempPaymentOrders)
                {
                    _repository.Add(tpOrders);
                }
            }
            else
            {
                WriteValues(tempPaymentOrders);
            }
            _unitOfWork.Save();
            SetState(ModelState.Saved);
        }
예제 #11
0
        public async Task <AccountRegisterResponse> Handle(AccountRegisterRequest request, CancellationToken cancellationToken)
        {
            var user = await _userRepository.GetOne(u => u.Login == request.Login);

            if (user != null)
            {
                return(new AccountRegisterResponse()
                {
                    Status = ResponseStatus.Error,
                    Message = "Пользователь с таким логином уже существует!"
                });
            }
            user = new UserEntity()
            {
                Created  = DateTime.Now,
                Login    = request.Login,
                Password = request.Password,
                Name     = request.Name,
                LastName = request.LastName
            };
            _userRepository.Add(user);

            await _userRepository.SaveChangesAsync();

            return(new AccountRegisterResponse()
            {
                Status = ResponseStatus.Success
            });
        }
예제 #12
0
        void Save()
        {
            if (!ValidData())
            {
                string msg = null;
                foreach (var viol in RulesViolations)
                {
                    msg += viol.ErrorMessage;
                }
                RulesViolations.Clear();
                Helper.ShowMessage(msg);
                return;
            }

            try
            {
                WriteModelValues(_currnetModel);
                if (_modelState == ModelState.New)
                {
                    PaymentStatus status = _unitOfWork.PaymentStatuses.GetById(1); //Initiated
                    _currnetModel.PaymentStatus = status;
                    _repository.Add(_currnetModel);
                }
                _unitOfWork.Save();
                SetState(ModelState.Saved);
            }
            catch (Exception ex)
            {
                Helper.LogAndShow(ex);
            }
        }
예제 #13
0
        void Save()
        {
            if (!ValidData())
            {
                string msg = null;
                foreach (var viol in RulesViolations)
                {
                    msg += viol.ErrorMessage;
                }
                RulesViolations.Clear();
                Helper.ShowMessage(msg);
                return;
            }

            try
            {
                WriteModelValues(_currnetModel);
                if (_modelState == ModelState.New)
                {
                    _currnetModel.LoanStatus = LoansStatuses.Single(x => x.Id == 1);
                    _repository.Add(_currnetModel);
                }
                _unitOfWork.Save();
                SetState(ModelState.Saved);
            }
            catch (Exception ex)
            {
                string msg = Helper.ProcessExceptionMessages(ex);
                Helper.ShowMessage(msg);
            }
        }
예제 #14
0
        private void WriteModelValues(IList <PostLoan> loansToPost)
        {
            string max     = Helper.GenerateLoanNo(SelectedFuture.YearPart);
            int    counter = 0;

            foreach (var loan in loansToPost)
            {
                var member     = _unitOfWork.FamilyMembers.GetById(loan.MemberCode);
                var loanStatus = _unitOfWork.LoanStatuses.GetById(1);
                var loanTypo   = _unitOfWork.LoanTypes.GetById(loan.LoanTypeId);
                var loanYear   = SelectedFuture;
                var paySequ    = _unitOfWork.PaymentSequences.GetById(loan.PaymentSequenceId);

                Loan postedLoan = new Loan()
                {
                    LoanNo          = Helper.AutoIncrement(max, counter),
                    LoanType        = loanTypo,
                    FamilyMember    = member,
                    PeriodSetting   = loanYear,
                    LoanStatus      = loanStatus,
                    PaymentSequence = paySequ,
                    Amount          = loan.LoanAmount,
                    Paid            = 0.0M,
                    Balance         = loan.LoanAmount
                };
                _loansRepository.Add(postedLoan);
                counter++;
            }
        }
예제 #15
0
 public static ApplicationRole Add(ApplicationRole appRole)
 {
     if (RepositoryBase <ApplicationRole> .CheckContains(x => x.Description == appRole.Description))
     {
         throw new NameDuplicatedException("Tên không được trùng");
     }
     return(RepositoryBase <ApplicationRole> .Add(appRole));
 }
예제 #16
0
 public void log(string crashMsg)
 {
     repository.Add(new CrashLog {
         crash_msg = crashMsg, crash_time = DateTime.Now
     });
     repository.Save();
     repository.Commit();
 }
예제 #17
0
        public ActionResult LikeCreate(Like like)
        {
            like.SponsorID = CurrentUser.IdentityID;
            like.Date      = DateTime.Now;
            likeRepo.Add(like);

            return(RedirectToAction("LikeList"));
        }
예제 #18
0
        public void PessoaRepository_CreatePessoa()
        {
            var pessoaTest = PessoaTestsData.ObterPessoa();
            var novaPessoa = new Pessoa("Lucas", new Cpf("84591898644"), PessoaTestsData.ObterEndereco());

            _repositoryBase.Add(novaPessoa);

            Assert.AreEqual(pessoaTest, _repositoryBase.GetById(pessoaTest.Id));
        }
예제 #19
0
        private static bool AddRoleGroups(IEnumerable <ApplicationRoleGroup> roleGroups)
        {
            foreach (var roleGroup in roleGroups)
            {
                RepositoryBase <ApplicationRoleGroup> .Add(roleGroup);
            }
            RepositoryBase <ApplicationRoleGroup> .SaveChanges();

            return(true);
        }
예제 #20
0
        public ActionResult Create(Blog blog)
        {
            var currentUser = new UserRepository().GetCurrentUser();

            blog.PosterID = currentUser.IdentityID;
            blog.Date     = DateTime.Now;
            blogRepo.Add(blog);

            return(RedirectToAction("Home", new { id = currentUser.IdentityID, page = 1 }));
        }
예제 #21
0
        public static bool AddUserGroups(IEnumerable <ApplicationUserGroup> userGroups)
        {
            foreach (var userGroup in userGroups)
            {
                RepositoryBase <ApplicationUserGroup> .Add(userGroup);
            }
            RepositoryBase <ApplicationUserGroup> .SaveChanges();

            return(true);
        }
예제 #22
0
        public static Audit Add(AuditVM item)
        {
            Audit dbItem = new Audit();

            dbItem.UpdateAudit(item);
            Audit model = RepositoryBase <Audit> .Add(dbItem);

            RepositoryBase <Company> .SaveChanges();

            return(dbItem);
        }
예제 #23
0
        public static ApplicationGroup Add(ApplicationGroup appGroup)
        {
            if (RepositoryBase <ApplicationGroup> .CheckContains(x => x.Name == appGroup.Name))
            {
                throw new NameDuplicatedException("Tên không được trùng");
            }
            ApplicationGroup item = RepositoryBase <ApplicationGroup> .Add(appGroup);

            RepositoryBase <ApplicationGroup> .SaveChanges();

            return(item);
        }
 public void CreateSubscriber(SubscriberInfo subscriberInfo, Subscriber subscriber)
 {
     if (subscriber == null)
     {
         var mappedSub = subscriberInfo.Get <SubscriberInfo, Subscriber>();
         subscriberRepository.Add(mappedSub);
         subscriberRepository.SaveChanges();
     }
     else if (subscriber.IsRemoved)
     {
         ToggleRemove(subscriber, false);
     }
 }
예제 #25
0
        public EWSUser Register(string username, string pass, string namesurname)
        {
            RepositoryBase <EWSUser> _rep = new RepositoryBase <EWSUser>();

            EWSUser ouser = new EWSUser()
            {
                Name     = namesurname,
                Password = pass,
                UserName = username,
            };

            return(_rep.Add(ouser));
        }
예제 #26
0
        public void agentconnect(string name, string email, string idsignlr, string idurl)
        {
            IEnumerable <chatagent2> listagent = _Chatagent.GetAll().Where(x => x.email == email); chatagent2 agent2 = new chatagent2 {
                name = name, email = email, idchat = idurl, urlchat = idsignlr
            }; _Chatagent.Add(agent2); IEnumerable <chatclient> listclient = _ChatClient.GetAll().Where(x => x.idchat == idurl); foreach (var clients in listclient)

            {
                Clients.Client(Context.ConnectionId).updateclientonline(clients.name, clients.email, clients.sdt, clients.ip, clients.addweb, clients.ip + "bb", clients.urlchat, clients.value1, clients.value2, clients.value3, clients.value4); Clients.Client(clients.urlchat).updatereconnect(email);
            }
            foreach (var agnets in listagent)
            {
                Clients.Client(agnets.urlchat).disconnectsameagnt();
            }
        }
예제 #27
0
        public static bool AddUserToGroups(IEnumerable <ApplicationGroup> groups, string userId)
        {
            foreach (var group in groups)
            {
                RepositoryBase <ApplicationUserGroup> .Add(new ApplicationUserGroup()
                {
                    GroupId = group.Id,
                    UserId  = userId,
                });
            }
            RepositoryBase <ApplicationUserGroup> .SaveChanges();

            return(true);
        }
예제 #28
0
        public TEntity Post(FormDataCollection form)
        {
            TEntity entity = Serialize(form);

            if (ModelState.IsValid)
            {
                _repository.Add(entity);
            }
            else
            {
                ErrorValidation();
            }
            return(entity);
        }
        public ActionResult Register(UserDetail userdetail)
        {
            userdetail.Ticket = Guid.NewGuid().ToString();
            userRepository.Add(userdetail);

            bool cvp = MailHelper.AktivasyonKoduGonder(userdetail.UserName, userdetail.Email, userdetail.Ticket);

            if (cvp)
            {
                return(RedirectToAction("Login"));
            }

            return(View());
        }
예제 #30
0
        public EWSSampleSentence SaveSentence(EWSSampleSentence _sentence)
        {
            IRepositoryBase <EWSSampleSentence> _repSentence = new RepositoryBase <EWSSampleSentence>();

            EWSSampleSentence sentence = new EWSSampleSentence();

            sentence.UN           = _sentence.UN;
            sentence.Sentence     = _sentence.Sentence;
            sentence.SentenceMean = _sentence.SentenceMean;

            _repSentence.Add(sentence);

            return(sentence);
        }