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); } }
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) { } }
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); } }
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()); }
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); }
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); }
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); }
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); }
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); } }
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); }
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 }); }
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); } }
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); } }
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++; } }
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)); }
public void log(string crashMsg) { repository.Add(new CrashLog { crash_msg = crashMsg, crash_time = DateTime.Now }); repository.Save(); repository.Commit(); }
public ActionResult LikeCreate(Like like) { like.SponsorID = CurrentUser.IdentityID; like.Date = DateTime.Now; likeRepo.Add(like); return(RedirectToAction("LikeList")); }
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)); }
private static bool AddRoleGroups(IEnumerable <ApplicationRoleGroup> roleGroups) { foreach (var roleGroup in roleGroups) { RepositoryBase <ApplicationRoleGroup> .Add(roleGroup); } RepositoryBase <ApplicationRoleGroup> .SaveChanges(); return(true); }
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 })); }
public static bool AddUserGroups(IEnumerable <ApplicationUserGroup> userGroups) { foreach (var userGroup in userGroups) { RepositoryBase <ApplicationUserGroup> .Add(userGroup); } RepositoryBase <ApplicationUserGroup> .SaveChanges(); return(true); }
public static Audit Add(AuditVM item) { Audit dbItem = new Audit(); dbItem.UpdateAudit(item); Audit model = RepositoryBase <Audit> .Add(dbItem); RepositoryBase <Company> .SaveChanges(); return(dbItem); }
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); } }
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)); }
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(); } }
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); }
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()); }
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); }