public IActionResult PostAuth(RequestCustomer request) { var authentication = request.data.attributes; Customer result; try { result = _context.customers.First(x => x.username == authentication.username); var tokenHandler = new JwtSecurityTokenHandler(); var tokenDescription = new SecurityTokenDescriptor() { Subject = new ClaimsIdentity(new Claim[] { new Claim(ClaimTypes.Name, authentication.username), new Claim(ClaimTypes.Authentication, authentication.password) }), Expires = DateTime.UtcNow.AddMonths(1), SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(Encoding.ASCII.GetBytes("this is some secret shit")), SecurityAlgorithms.HmacSha512Signature) }; var token = tokenHandler.CreateToken(tokenDescription); var tokenResponse = new { token = tokenHandler.WriteToken(token), customer = result }; return(Ok(tokenResponse)); } catch (Exception) { return(NotFound()); } }
public IActionResult UpdatebyId(int id, RequestCustomer request) { var auth = request.data.attributes; try { var result = _context.customers.First(x => x.id == id); result.full_name = auth.full_name; result.username = auth.username; result.email = auth.email; result.phone_number = auth.phone_number; result.updated_at = timestamp; _context.SaveChanges(); return(Ok(new { message = "success update data", status = "true", data = result })); } catch (Exception) { return(NotFound()); } }
public async Task ExecuteAsync(RequestCustomer requestCustomer) { var requestCustomerRepo = Uow.GetRepository <RequestCustomer>(); requestCustomerRepo.Update(requestCustomer); await Uow.SaveChangesAsync(); }
public IHttpActionResult updateCustomer(RequestCustomer request) { request.UserName = User.Identity.Name; IRepositoryCustomer customer = new Customer(); return(Json(customer.UpdateCustomer(request))); }
public IHttpActionResult addCustomer(RequestCustomer request) { request.UserName = User.Identity.Name; request.URL = this.Url.Link("Default", new { Controller = "Account", Action = "Login" }); IRepositoryCustomer customer = new Customer(); return(Json(customer.AddCustomer(request))); }
public int Execute(RequestCustomer requestCustomer) { var repo = Uow.GetRepository <RequestCustomer>(); repo.Create(requestCustomer); Uow.SaveChanges(); return(requestCustomer.Id); }
public async Task <int> ExecuteAsync(RequestCustomer requestCustomer) { var requestCustomerRepo = Uow.GetRepository <RequestCustomer>(); await requestCustomerRepo.CreateAsync(requestCustomer); await Uow.SaveChangesAsync(); return(requestCustomer.Id); }
public string AllRequest(RequestCustomer model) { if (db.Requests.Where(r => r.id_customer == model.id_customer).ToList() != null && model != null) { var requests = db.Requests.Where(r => r.id_customer == model.id_customer).ToList(); var json = JsonConvert.SerializeObject(requests, Formatting.Indented); return(json); } else { return("Нет ни одного заказа"); } }
public IActionResult Post(RequestCustomer request) { var auth = request.data.attributes; var customer = new Customer() { full_name = auth.full_name, username = auth.username, email = auth.email, phone_number = auth.phone_number, created_at = timestamp, updated_at = timestamp }; _context.customers.Add(customer); _context.SaveChanges(); return(Ok(new { message = "success add data", status = "true", data = customer })); }
/// <summary> /// Получает идентификатор адресата для переписки по идентификатору заявки. /// </summary> /// <param name="requestId">Идентификатор заявки.</param> /// <returns>Иденификатор адресата для переписки.</returns> private async Task <int?> GetAddresseeIdByRequestId(int requestId) { Request request = await Executor .GetQuery <GetRequestByIdWithCustomersAndCustomerRolesQuery>() .Process(query => query.ExecuteAsync(requestId)); if (request is null) { throw new DataNotFoundException(nameof(Request), DataNotFoundException.OperationType.Read, requestId); } RequestCustomer addressee = request.RequestCustomers .FirstOrDefault(customer => customer.CustomerRole.Code == DicCustomerRoleCodes.Correspondence); return(addressee?.CustomerId); }
public void RequisitionBlockCustomerAdd(Customer[] customers, int requestId) { foreach (var item in customers) { if (item.Type == null) { continue; } var customer = new DicCustomer { TypeId = _dictionaryHelper.GetDictionaryEntityByExternalId(nameof(DicCustomerType), item.Type.UID).Id, NameRu = item.NameRu, NameKz = item.NameKz, NameEn = item.NameEn, Phone = item.Phone, PhoneFax = item.Fax, Email = item.Email, Address = $"{item.AdrObl}, {item.AdrStreet}, {item.AdrPostCode}", CertificateNumber = item.CertificateNumber, CertificateSeries = item.CertificateSeries, Opf = item.Opf, ApplicantsInfo = item.ApplicantsInfo, PowerAttorneyFullNum = item.PowerAttorneyFullNum, ShortDocContent = item.ShortDocContent, Xin = item.Xin, NotaryName = item.NotaryName, DateCreate = DateTimeOffset.Now }; if (item.RegDate != DateTime.MinValue) { customer.RegDate = new DateTimeOffset(item.RegDate); } var requestCustomer = new RequestCustomer { CustomerId = _integrationDictionaryHelper.GetCustomerIdOrCreateNew(customer).Id, RequestId = requestId, DateCreate = DateTimeOffset.Now, CustomerRoleId = _dictionaryHelper.GetDictionaryEntityByExternalId(nameof(DicCustomerRole), item.PatentLinkType.UID)?.Id }; _niisContext.RequestCustomers.Add(requestCustomer); _niisContext.SaveChanges(); } }
private async Task <RequestCustomer> CreateCustomer(RfCustomerAddressExtention oldCustomer, int requestId) { try { var customerId = GetObjectId <DicCustomer>(oldCustomer.CustomerId); if ((customerId == null || customerId == 0) && oldCustomer.CustomerId.HasValue) { customerId = await GetCustomer(oldCustomer.CustomerId.Value); } if (customerId == null || customerId == 0) { return(null); } var customer = new RequestCustomer { Address = oldCustomer.AddresNameRu, CustomerId = customerId, CustomerRoleId = GetObjectId <DicCustomerRole>(oldCustomer.CType), DateCreate = new DateTimeOffset(oldCustomer.DateCreate.GetValueOrDefault(DateTime.Now)), DateUpdate = new DateTimeOffset(oldCustomer.Stamp.GetValueOrDefault(DateTime.Now)), DateBegin = GetNullableDate(oldCustomer.DateBegin), DateEnd = GetNullableDate(oldCustomer.DateEnd), ExternalId = oldCustomer.Id, RequestId = requestId, Timestamp = BitConverter.GetBytes(DateTime.Now.Ticks), AddressEn = oldCustomer.AddresNameEn, AddressKz = oldCustomer.AddresNameKz }; return(customer); } catch (Exception) { return(null); } }
public IHttpActionResult Post(RequestCustomer requestCustomer) { var result = _customersPostFacade.Post(requestCustomer); return(GetHttpActionResult(result)); }
public IResult <Error> Put(int id, RequestCustomer requestCustomer) { var commandResult = Command.TryCreate(id, requestCustomer.Version, requestCustomer.Name, requestCustomer.Surname, requestCustomer.PhoneNumber, requestCustomer.Address); return(Helper.Update(_mediator, commandResult)); }
public string updateUnifyCustomer(RequestCustomer request) { request.UserName = User.Identity.Name; request.URL = this.Url.Link("Default", new { Controller = "Account", Action = "Login" }); IRepositoryCustomer customer = new Customer(); ResultJson jsonResult = new ResultJson(); // Primero Hace la Unificación y si es Correcto hace la Actualización de Socia using (DbContextJulio db = new DbContextJulio()) { var aspnetusers_id = db.AspNetUsers.Where(s => s.UserName == User.Identity.Name).FirstOrDefault().Id; dynamic _participante = null; if (!string.IsNullOrEmpty(request.Correo)) { _participante = (from p in db.participante join t in db.transaccion on p.id equals t.participante_id where p.correo_electronico == request.Correo.Trim() && p.status_participante_id != 13 && p.status_participante_id != 14 && t.tipo_transaccion_id == 1 && p.id != request.Id select new { id = p.id, clave = p.clave, fecha = t.fecha } ).OrderByDescending(t => t.fecha).FirstOrDefault(); } if (_participante == null) { if (!string.IsNullOrEmpty(request.Tel_celular) && request.Tel_celular.Trim() != "0") { _participante = (from p in db.participante join pt in db.participante_telefono on p.id equals pt.participante_id join t in db.transaccion on p.id equals t.participante_id where pt.telefono == request.Tel_celular.Trim() && pt.tipo_telefono_id == 3 && p.status_participante_id != 13 && p.status_participante_id != 14 && t.tipo_transaccion_id == 1 && p.id != request.Id select new { id = p.id, clave = p.clave, fecha = t.fecha }).OrderByDescending(t => t.fecha).FirstOrDefault(); } } // Conserva el status del participante actual, en caso de haber un error decimal status_participante_id = customer.ObtieneStatusPartipanteId(request); // Actualiza status participante como activo customer.ActualizaStatusParticipante(request, 2); Dictionary <string, object> parameters = new Dictionary <string, object>(); parameters.Add("@transferencia", "UNIFICACION"); parameters.Add("@NoTarjeta", _participante.clave); parameters.Add("@NuevaTarjeta", request.Num_tarjeta); parameters.Add("@participante_id", _participante.id); parameters.Add("@aspnetusers_id", aspnetusers_id); DataSet setTables = db.GetDataSet("[dbo].[usp_transfiere_tarjeta]", CommandType.StoredProcedure, parameters); if (setTables.Tables[0].Rows[0]["errorId"].ToString() == "0") { // Actualiza status participante como estaba. Esto para que permita pasar el proceso de actualizar socia customer.ActualizaStatusParticipante(request, status_participante_id); jsonResult = customer.UpdateCustomer(request); jsonResult.jsonObject = JsonConvert.SerializeObject(setTables.Tables[0]); } else // Ocurrio un error se regresa como estaba el status del participante { // Actualiza status participante como estaba customer.ActualizaStatusParticipante(request, status_participante_id); jsonResult.jsonObject = JsonConvert.SerializeObject(setTables.Tables[0]); } } return(JsonConvert.SerializeObject(jsonResult)); }
public IResult <int, Error> Post(RequestCustomer requestCustomer) { var commandResult = Command.TryCreate(requestCustomer.Name, requestCustomer.Surname, requestCustomer.PhoneNumber, requestCustomer.Address); return(Helper.Insert <int, Command, PositiveInt>(_mediator, _mapper, commandResult)); }