示例#1
0
 /// <summary>
 /// updates phone number
 /// </summary>
 /// <param name="phone"> phone number </param>
 public void UpdatePhone(UpdatePhone phone)
 {
     using (var _ctx = new ChinmayaEntities())
     {
         var user = _ctx.Users.Where(r => r.Email == phone.Email).FirstOrDefault();
         if (user != null)
         {
             user.CellPhone = phone.OldPhone;
         }
         try
         {
             _ctx.SaveChanges();
         }
         catch (DbEntityValidationException e)
         {
             foreach (var even in e.EntityValidationErrors)
             {
                 Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                   even.Entry.Entity.GetType().Name, even.Entry.State);
                 foreach (var ve in even.ValidationErrors)
                 {
                     Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                       ve.PropertyName, ve.ErrorMessage);
                 }
             }
         }
     }
 }
        public BusinessLogic(
            ILoggerService logger,
            ILoggerFactory loggerFactory,
            IConfiguration configuration,
            TypeAdapterConfig mapping,
            UnitOfWork service1C,
            //ServiceLibraryNeoClient.Implements.DataManager neo,
            Lazy <ServiceLibraryNeoClient.Implements.DataManager> neo,
            IDataManager amocrm)
        {
            this.logger        = logger; // Логи
            this.loggerFactory = loggerFactory;
            this.currentLogger = loggerFactory.CreateLogger(this.ToString());

            this.mapper = mapping;  // Maps
            new RegisterCommonMaps(mapper);

            this.crm      = amocrm;    // Amo
            this.database = service1C; // 1C

            neodatabase = neo.Value;   // neo

            // Events
            updGuid  = new UpdateGuid(crm, database, eventsType, mapper, loggerFactory);
            updPhone = new UpdatePhone(crm, eventsType, mapper, loggerFactory);
            sendLead = new SendLeadTo1CEvent(crm, database, eventsType, mapper, loggerFactory);

            //new RegisterMapsterConfig();
        }
        public BusinessLogic(ILogger logger, IConfiguration configuration, TypeAdapterConfig mapping)
        {
            this.logger = logger;
            this.mapper = mapping;
            new RegisterMaps(mapper);


            var amoAccount = configuration.GetSection("providers:0:AmoCRM:connection:account:name").Value;
            var amoUser    = configuration.GetSection("providers:0:AmoCRM:connection:account:email").Value;
            var amoPass    = configuration.GetSection("providers:0:AmoCRM:connection:account:hash").Value;

            var user1C = configuration.GetSection("providers:1:1C:connection:account:user").Value;
            var pass1C = configuration.GetSection("providers:1:1C:connection:account:pass").Value;

            this.amocrm = new DataManager(amoAccount, amoUser, amoPass);

            this.database = new UnitOfWork(user1C, pass1C);

            neo = new Lazy <ServiceLibraryNeoClient.Implements.DataManager>();


            //updGuid = new UpdateGuid(amocrm, database, eventsType, mapper, logger);
            updPhone = new UpdatePhone(amocrm, eventsType, mapper, logger);
            //CreateUser = new CreateUser(amocrm, database, eventsType, mapper, logger);

            new RegisterMapsterConfig();
        }
 public IHttpActionResult UpdatePhone(UpdatePhone obj)
 {
     try
     {
         _user.UpdatePhone(obj);
         return(Ok("Success"));
     }
     catch (Exception)
     {
         return(Ok("Something went wrong"));
     }
 }
示例#5
0
 public IHttpActionResult UpdatePhone(UpdatePhone obj)
 {
     try
     {
         _user.UpdatePhone(obj);
         return(Ok("Success"));
     }
     catch
     {
         throw;
     }
 }
示例#6
0
 /// <summary>
 /// gets User phone no.
 /// </summary>
 /// <param name="Email"> user email </param>
 /// <returns> Update Phone model </returns>
 public UpdatePhone getPhoneNumber(string Id)
 {
     using (var _ctx = new ChinmayaEntities())
     {
         UpdatePhone phone = new UpdatePhone();
         var         pData = _ctx.Users.Where(f => f.Email == Id).FirstOrDefault();
         if (pData != null)
         {
             phone.Email    = Id;
             phone.OldPhone = pData.CellPhone;
         }
         return(phone);
     }
 }
示例#7
0
        void IDataSender.UpdatePhone(UpdatePhone update)
        {
            Datagram datagram = new Datagram
            {
                DataType    = DatagramType.Login,
                MessageType = LoginMessageType.UpdatePhone,
                Datas       = update.ToByteArray()
            };

            if (!Send(datagram))
            {
                RunningDatas.InfoNotify("网络连接失败 请重启软件后重试");
            }
        }
示例#8
0
 /// <summary>
 /// updates phone number
 /// </summary>
 /// <param name="phone"> phone number </param>
 public void UpdatePhone(UpdatePhone phone)
 {
     using (var _ctx = new ChinmayaEntities())
     {
         var user = _ctx.Users.Where(r => r.Email == phone.Email).FirstOrDefault();
         if (user != null)
         {
             user.CellPhone = phone.OldPhone;
         }
         try
         {
             _ctx.SaveChanges();
         }
         catch
         {
             throw;
         }
     }
 }
        public async Task <ActionResult> ChangePhone(UpdatePhone Info)
        {
            ToastModel tm   = new ToastModel();
            string     role = await _common.GetUserRoleName(User.Identity.Name);

            if (ModelState.IsValid)
            {
                UpdatePhone phoneModel = new UpdatePhone();
                phoneModel.Email    = User.Identity.Name;
                phoneModel.OldPhone = Info.OldPhone;
                HttpResponseMessage userResponseMessage = await Utility.GetObject("/api/User/UpdatePhone", phoneModel, true);

                tm.IsSuccess = true;
                tm.Message   = "Phone updated successfully";
                return(Json(tm));
            }

            return(RedirectToAction("EditPhoneNumber", "Common"));
        }
        public async Task <ActionResult> ChangePhone(UpdatePhone Info, string nextBtn)
        {
            ToastModel tm = new ToastModel();

            if (nextBtn != null)
            {
                if (ModelState.IsValid)
                {
                    UpdatePhone phoneModel = new UpdatePhone();
                    phoneModel.Email    = User.Identity.Name;
                    phoneModel.OldPhone = Info.OldPhone;
                    HttpResponseMessage userResponseMessage = await Utility.GetObject("/api/User/UpdatePhone", phoneModel, true);

                    tm.IsSuccess = true;
                    tm.Message   = "Phone updated successfully";
                    return(Json(tm));
                }
            }
            return(RedirectToAction("MyAccount", "Account"));
        }
        public async Task <PartialViewResult> EditPhoneNumber()
        {
            UpdatePhone phone = await _user.getPhoneNumber(User.Identity.Name);

            return(PartialView("_ChangePhone", phone));
        }
        public async Task <PartialViewResult> EditPhoneNumber(string Email)
        {
            UpdatePhone phone = await _user.getPhoneNumber(Email);

            return(PartialView("_ChangePhone", phone));
        }
示例#13
0
        private void OnUpdatePhone(Datagram datagram)
        {
            UpdatePhone update = datagram.UnSerialData <UpdatePhone>();

            SQLDB.UpdatePhone(update.UserID, update.UserPhone);
        }
 public Task <Response> UpdatePhone(UpdatePhone command)
 {
     return(_appLayer.Execute(command));
 }