public async Task <JsonResult> EditCustomer(string tenantUid, string title, string firstname, string lastname, string gender, string day, string month, string year, string country, string countrycode, string timezone, string odds, string language, string username, string customerGuid, string customerToken, string address1 = "", string address2 = "", string address3 = "", string town = "", string county = "", string postalcode = "", string notify = "true")
        {
            var customer = new EditCustomer
            {
                Username = username,
                Fields   = new Models.EditCustomer.EditFields
                {
                    CountryCode         = countrycode,
                    DOB                 = !string.IsNullOrEmpty(day) ? $"{year}-{month}-{day}" : string.Empty,
                    FirstName           = firstname,
                    LastName            = lastname,
                    Gender              = gender,
                    LanguageCode        = language,
                    OddsDisplay         = odds,
                    TimeZoneCode        = timezone,
                    Title               = title,
                    AddressLine1        = address1,
                    AddressLine2        = address2,
                    AddressLine3        = address3,
                    County              = county,
                    Town                = town,
                    Country             = country,
                    PostCode            = postalcode,
                    NotificationComPref = notify
                }
            };
            var origin        = TenantHelper.GetCurrentTenantUrl(contentService, tenantUid);
            var key           = ApiKeyCache.GetByTenantUid(tenantUid);
            var authorization = await new Authorization().GetAuthorizationAsync(key);

            var response = await apiService.EditCustomerAsync(customer, tenantUid, origin, customerToken);

            return(Json(response, JsonRequestBehavior.DenyGet));
        }
        public ActionResult <EditCustomer> EditCustomer(EditCustomer model)
        {
            try
            {
                IMapper mapper    = EDeliveryProfile.EditCustomer();
                var     newResult = mapper.Map <Customer>(model);

                var userIdClaim = User.FindFirst("MemberId")?.Value;
                var memberId    = int.TryParse(userIdClaim, out var id) ? id : 0;

                newResult.MemberId = memberId;

                EDeliveryDBContext dBContext = new EDeliveryDBContext();
                var customerId = dBContext.Customer.First(o => o.MemberId == memberId).CustomerId;
                newResult.CustomerId = customerId;

                var locationId = dBContext.Location.First(o => o.CustomerId == customerId).LocationId;
                locationId = newResult.Location.Select(o => o.LocationId).FirstOrDefault();

                _repository.EditCustomer(newResult);

                return(new ObjectResult(new { message = "success", statusCode = HttpStatusCode.OK, response = "Succesfuly edited customer" }));
            }
            catch (Exception ex)
            {
                _logger.LogError($"Failed to edit the customer:{ex}");
            }
            return(BadRequest("Failed to edit the customer."));
        }
        public async Task <IActionResult> Create([FromBody] EditCustomer model)
        {
            var customer = new Customer {
                Firstname = model.Firstname, Lastname = model.Lastname
            };
            await _context.Customers.AddAsync(customer);

            await _context.SaveChangesAsync();

            return(Ok(Mappers.Map(customer)));
        }
示例#4
0
 private void Border_MouseLeftButtonDown_1(object sender, MouseButtonEventArgs e)
 {
     if (CustomerVerification())
     {
         var editCustomer = new EditCustomer(customerId);
         editCustomer.Show();
     }
     else
     {
         MessageBox.Show("Please select the customer");
     }
 }
        public ModelStateDictionary CheckIfEditedChangesAreValid(EditCustomer customerToEdit)
        {
            TryValidateModel(customerToEdit);

            if (ModelState.IsValid)
            {
                return(ModelState);
            }
            else
            {
                return(ModelState);
            }
        }
        public async Task <IActionResult> Edit(CustomerId id, [FromBody] EditCustomer model)
        {
            var customer = await _context.GetCustomerAsync(id);

            if (customer == null)
            {
                return(NotFound());
            }
            customer.Firstname = model.Firstname;
            customer.Lastname  = model.Lastname;
            await _context.SaveChangesAsync();

            return(Ok(Mappers.Map(customer)));
        }
        public async Task <IResponseContent> EditCustomerAsync(EditCustomer customer, string tenantUid, string origin, string token)
        {
            try
            {
                IRestResponse response = await SubmitPostAsync(URL_EDIT_CUSTOMER, origin, customer, token, tenantUid);

                return(await AssertResponseContentAsync <EditCustomerResponseContent>(response));
            }
            catch (Exception ex)
            {
                return(new EditCustomerResponseContent
                {
                    Exception = ex
                });
            }
        }
示例#8
0
        public async Task SaveCustomer(EditCustomer customer)
        {
            using (var db = new CoreContext())
            {
                var dbCustomer = await db.Customers.FirstAsync(x => x.Id == customer.Id);

                // AutoMapper
                dbCustomer.City        = customer.City;
                dbCustomer.CompanyName = customer.CompanyName;
                dbCustomer.FirstName   = customer.FirstName;
                dbCustomer.PostalCode  = customer.PostalCode;
                dbCustomer.Street      = customer.Street;

                // 2 SQL Statements
                //UPDATE abhängig aus der Änderung zwischen Datenbankwerten (!) <--> customer
                await db.SaveChangesAsync();
            }
        }
示例#9
0
        //edit user
        private void edit_btn_Click(object sender, EventArgs e)
        {
            if (listView1.SelectedItems.Count == 0)
            {
                return;
            }

            using (EditCustomer ec = new EditCustomer())
            {
                ListViewItem item = listView1.SelectedItems[i];
                string       name = item.SubItems[0].Text;
                string       id   = item.SubItems[1].Text;
                ec.name_txt.Text = name.ToString();
                ec.id_txt.Text   = id.ToString();

                ec.ShowDialog(this);
            }
        }
示例#10
0
        public ActionResult Edit(int id)
        {
            var service = CreateCustomerService();
            var detail  = service.GetCustomerById(id);
            var model   =
                new EditCustomer
            {
                CustomerID = detail.CustomerID,
                Name       = detail.Name,
                Address    = detail.Address,
                Telephone  = detail.Telephone,
                Email      = detail.Email,
                Notes      = detail.Notes,
                // OwnerId = detail.OwnerId
            };

            return(View(model));
        }
示例#11
0
 public ActionResult Edit(Customer c)
 {
     try
     {
         var request = new EditCustomer()
         {
             Id              = c.Id,
             Name            = c?.Name,
             Surname         = c?.Surname,
             EmailAddress    = c?.EmailAddress,
             TelephoneNumber = c?.TelephoneNumber
         };
         mediator.Send(request);
         return(RedirectToAction(nameof(Index)));
     }
     catch
     {
         return(View());
     }
 }
示例#12
0
        public bool UpdateCustomer(EditCustomer model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .Customer
                    .Single(e => e.CustomerID == model.CustomerID && e.OwnerId == _userId);

                entity.CustomerID = model.CustomerID;
                entity.Name       = model.Name;
                entity.Address    = model.Address;
                entity.Telephone  = model.Telephone;
                entity.Email      = model.Email;
                entity.Notes      = model.Notes;
                //      entity.OwnerId = model.OwnerId;

                return(ctx.SaveChanges() == 1);
            }
        }
示例#13
0
        public IHttpActionResult Edit(EditCustomer customer)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var customerToEdit = _db.Customers.SingleOrDefault(c => c.Id == customer.Id);

            if (customerToEdit == null)
            {
                return(BadRequest());
            }

            customerToEdit.Name    = customer.Name;
            customerToEdit.Company = customer.Company;
            customerToEdit.Email   = customer.Email;
            customerToEdit.Phone   = customer.Phone;

            _db.SaveChanges();

            return(Ok());
        }
示例#14
0
        public ActionResult Edit(EditCustomer model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (model.CustomerID != model.CustomerID)
            {
                ModelState.AddModelError("", "Id Mismatch");
                return(View(model));
            }

            var service = CreateCustomerService();

            if (service.UpdateCustomer(model))
            {
                TempData["SaveResult"] = "Your note was updated.";
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", "Your note could not be updated.");
            return(View(model));
        }
示例#15
0
 public int EditCustomer(EditCustomer request)
 {
     try
     {
         DynamicParameters parameters = new DynamicParameters();
         parameters.Add("@customer_id", request.customer_id);
         parameters.Add("@first_name", request.first_name);
         parameters.Add("@last_name", request.last_name);
         parameters.Add("@gender", request.gender);
         parameters.Add("@address", request.address);
         parameters.Add("@city", request.city);
         parameters.Add("@email", request.email);
         parameters.Add("@phone_number", request.phone_number);
         parameters.Add("@description", request.description);
         parameters.Add("@job_id", request.job_id);
         parameters.Add("@imgUrl", request.imgUrl);
         int id = SqlMapper.ExecuteScalar <int>(con, "Cus_EditCustomer", param: parameters, commandType: CommandType.StoredProcedure);
         return(id);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#16
0
        public async Task SaveCustomer(EditCustomerEntry originalCustomer, EditCustomer customer)
        {
            using (var db = new CoreContext())
            {
                var dbCustomer = new Customers();
                dbCustomer.Id          = originalCustomer.Id;
                dbCustomer.City        = originalCustomer.City;
                dbCustomer.CompanyName = originalCustomer.CompanyName;
                dbCustomer.FirstName   = originalCustomer.FirstName;
                dbCustomer.PostalCode  = originalCustomer.PostalCode;
                dbCustomer.Street      = originalCustomer.Street;
                db.Customers.Attach(dbCustomer);

                dbCustomer.City        = customer.City;
                dbCustomer.CompanyName = customer.CompanyName;
                dbCustomer.FirstName   = customer.FirstName;
                dbCustomer.PostalCode  = customer.PostalCode;
                dbCustomer.Street      = customer.Street;

                // NUR 1 SQL Statement!
                // UPDATE abhängig aus der Änderung zwischen orignalCustomer <--> customer
                await db.SaveChangesAsync();
            }
        }
示例#17
0
        async void SaveShipTo()
        {
            try
            {
                var answer = await dialogService.ShowConfirm(
                    "Confirmación",
                    "¿Guardar sucursal?");

                var connection = await netService.CheckConnectivity();

                if (!connection.IsSuccess)
                {
                    await dialogService.ShowMessage("Error", connection.Message);

                    return;
                }

                if (string.IsNullOrEmpty(NewShipTo.ShipToNum))
                {
                    await dialogService.ShowMessage(
                        "Error",
                        "Debes ingresar un ShipToNum.");

                    return;
                }

                if (string.IsNullOrEmpty(NewShipTo.ShipToName))
                {
                    await dialogService.ShowMessage(
                        "Error",
                        "Debes ingresar nombre de sucursal.");

                    return;
                }

                if (string.IsNullOrEmpty(NewShipTo.Description))
                {
                    await dialogService.ShowMessage(
                        "Error",
                        "Debes seleccionar un pais.");

                    return;
                }

                NewShipTo.IsRunning = true;

                //var UltimoRegistro = dataService
                //.Get<ShipTo>(false)
                //.OrderByDescending(t => t.ShipToId)
                //.FirstOrDefault();

                //if (UltimoRegistro.ShipToId == 0)
                //{
                //    UltimoRegistro.ShipToId = 1;

                //}else{

                //    UltimoRegistro.ShipToId = UltimoRegistro.ShipToId + 1;
                //}

                var shipto = new ShipTo
                {
                    ShipToId          = 0,
                    CustomerId        = NewShipTo.CustomerId,
                    CustNum           = EditCustomer.Customer.CustNum,
                    ShipToNum         = NewShipTo.ShipToNum,
                    Company           = User.Company,
                    ShipToName        = NewShipTo.ShipToName,
                    TerritoryEpicorID = NewShipTo.TerritoryEpicorID,
                    Country           = NewShipTo.Description,
                    State             = NewShipTo.State,
                    City               = NewShipTo.City,
                    Address            = NewShipTo.Address,
                    PhoneNum           = NewShipTo.PhoneNum,
                    Email              = NewShipTo.Email,
                    SincronizadoEpicor = false,
                };



                #region Sincronizo Shipto
                var url = Application.Current.Resources["URLAPI"].ToString();

                var shiptorequest = new SyncShiptoRequest
                {
                    ShipToId          = shipto.ShipToId,
                    CustomerId        = shipto.CustomerId,
                    ShipToNum         = shipto.ShipToNum,
                    CustNum           = shipto.CustNum,
                    Company           = shipto.Company,
                    ShipToName        = shipto.ShipToName,
                    TerritoryEpicorID = shipto.TerritoryEpicorID,
                    Country           = shipto.Country,
                    State             = shipto.State,
                    City               = shipto.City,
                    Address            = shipto.Address,
                    PhoneNum           = shipto.PhoneNum,
                    Email              = shipto.Email,
                    VendorId           = User.VendorId,
                    SincronizadoEpicor = false,
                };


                var response = await apiService
                               .PostMaster(url, "/api/ShipToes", shiptorequest);

                if (!response.IsSuccess)
                {
                    await dialogService.ShowMessage("Error", response.Message);

                    return;
                }

                var syncShiptoRequest = (SyncShiptoRequest)response.Result;
                var ShipToToInsert    = new ShipTo
                {
                    Address            = syncShiptoRequest.Address,
                    City               = syncShiptoRequest.City,
                    Company            = syncShiptoRequest.Company,
                    Country            = syncShiptoRequest.Country,
                    CustNum            = syncShiptoRequest.CustNum,
                    CustomerId         = syncShiptoRequest.CustomerId,
                    Email              = syncShiptoRequest.Email,
                    PhoneNum           = syncShiptoRequest.PhoneNum,
                    ShipToId           = syncShiptoRequest.ShipToId,
                    ShipToName         = syncShiptoRequest.ShipToName,
                    ShipToNum          = syncShiptoRequest.ShipToNum,
                    SincronizadoEpicor = syncShiptoRequest.SincronizadoEpicor,
                    State              = syncShiptoRequest.State,
                    TerritoryEpicorID  = syncShiptoRequest.TerritoryEpicorID,
                    VendorId           = User.VendorId,
                };

                dataService.Insert(ShipToToInsert);
                NewShipTo.IsRunning = false;
                await dialogService.ShowMessage("Exito", "Se inserto el registro con exito.");

                EditCustomer.RefreshShipTo();
                await navigationService.Back();

                #endregion
            }
            catch (Exception ex)
            {
                await dialogService.ShowMessage("Error", ex.Message);
            }
        }
示例#18
0
 private void button_Click(object sender, RoutedEventArgs e)
 {
     EditCustomer f = new EditCustomer();
     f.Closing += AddCustomer_Closing;
     f.ShowDialog();
 }
示例#19
0
 public int EditCustomer([FromBody] EditCustomer request)
 {
     return(_customerService.EditCustomer(request));
 }
示例#20
0
 public int EditCustomer(EditCustomer request)
 {
     return(_customerRepository.EditCustomer(request));
 }