/// <summary> /// Updates the <see cref="CustomerGroup"/> object. /// </summary> /// <param name="value">The <see cref="CustomerGroup"/> object.</param> /// <returns>A refreshed <see cref="CustomerGroup"/> object.</returns> public Task <CustomerGroup> UpdateAsync(CustomerGroup value) { if (value == null) { throw new ArgumentNullException(nameof(value)); } return(DataInvoker.Default.InvokeAsync(this, async() => { CustomerGroup __result = null; var __dataArgs = ODataMapper.Default.CreateArgs(); if (_updateOnBeforeAsync != null) { await _updateOnBeforeAsync(value, __dataArgs).ConfigureAwait(false); } __result = await DynamicsAx.Default.UpdateAsync <CustomerGroup>(__dataArgs, value).ConfigureAwait(false); if (_updateOnAfterAsync != null) { await _updateOnAfterAsync(__result).ConfigureAwait(false); } return __result; }, new BusinessInvokerArgs { ExceptionHandler = _updateOnException })); }
public virtual async Task DeleteCustomerGroup(CustomerGroup customerGroup) { await _groupService.DeleteCustomerGroup(customerGroup); //activity log await _customerActivityService.InsertActivity("DeleteCustomerGroup", customerGroup.Id, _translationService.GetResource("ActivityLog.DeleteCustomerGroup"), customerGroup.Name); }
/// <summary> /// 构造函数 /// </summary> /// <param name="entity">客户分组领域实体对象</param> public CustomerGroupPageModel(CustomerGroup entity) { this.Id = entity.Id; this.Name = entity.Name; this.IsDefault = entity.IsDefault; this.Remark = entity.Remark; }
/// <summary> /// Updates the <see cref="CustomerGroup"/> object. /// </summary> /// <param name="value">The <see cref="CustomerGroup"/> object.</param> /// <param name="id">The <see cref="CustomerGroup"/> identifier.</param> /// <param name="company">The Company (see <see cref="RefDataNamespace.Company"/>).</param> /// <returns>A refreshed <see cref="CustomerGroup"/> object.</returns> public Task <CustomerGroup> UpdateAsync(CustomerGroup value, string id, RefDataNamespace.Company company) { return(ManagerInvoker.Default.InvokeAsync(this, async() => { ExecutionContext.Current.OperationType = OperationType.Update; if (value != null) { value.Id = id; value.Company = company; } EntityBase.CleanUp(value, id); if (_updateOnPreValidateAsync != null) { await _updateOnPreValidateAsync(value, id, company); } MultiValidator.Create() .Add(value.Validate(nameof(value)).Mandatory().Entity(CustomerGroupValidator.Default)) .Add(company.Validate(nameof(company)).IsValid()) .Additional((__mv) => _updateOnValidate?.Invoke(__mv, value, id, company)) .Run().ThrowOnError(); if (_updateOnBeforeAsync != null) { await _updateOnBeforeAsync(value, id, company); } var __result = await CustomerGroupDataSvc.UpdateAsync(value); if (_updateOnAfterAsync != null) { await _updateOnAfterAsync(__result, id, company); } Cleaner.Clean(__result); return __result; })); }
public async Task <IActionResult> PutCustomerGroup(int id, CustomerGroup customerGroup) { if (id != customerGroup.Id) { return(BadRequest()); } _context.Entry(customerGroup).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CustomerGroupExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <CustomerGroup> > PostCustomerGroup(CustomerGroup customerGroup) { _context.CustomerGroup.Add(customerGroup); await _context.SaveChangesAsync(); return(CreatedAtAction("GetCustomerGroup", new { id = customerGroup.Id }, customerGroup)); }
public async Task <ApiResult <PagedResult <AccountsDto> > > GetAccountsPagingAsync(int pageIndex, int pageSize) { var accounts = await(from au in _context.AppUsers join emp in _context.Employees on au.Id equals emp.AppuserId into EmployeeGroup from e in EmployeeGroup.DefaultIfEmpty() join cus in _context.Customers on au.Id equals cus.AppUserId into CustomerGroup from c in CustomerGroup.DefaultIfEmpty() join sup in _context.Suppliers on au.Id equals sup.AppUserId into SupplierGroup from s in SupplierGroup.DefaultIfEmpty() select new AccountsDto() { Id = au.Id, UserName = au.UserName, Email = au.Email, EmployeeName = e.Name, CustomerName = c.Name, SupplierName = s.Name, PhoneNumber = au.PhoneNumber }).GetPagedAsync(pageIndex, pageSize); return(new ApiResult <PagedResult <AccountsDto> >(HttpStatusCode.OK, accounts)); }
/// <summary> /// Render price with inplace editor /// </summary> /// <param name="productPrice">product price</param> /// <param name="discount">total discount price</param> /// <param name="showDiscount">display discount</param> /// <param name="customerGroup">customer group</param> /// <param name="customOptions">custom options</param> /// <param name="offerId">offer id</param> /// <returns></returns> public static string RenderPriceInplace(float productPrice, float discount, bool showDiscount, CustomerGroup customerGroup, string customOptions = null, int offerId = 0) { if (productPrice == 0) { return(String.Format("<div class=\'price-wrap\' {1}>{0}</div>", Resource.Client_Catalog_ContactWithUs, InplaceEditor.Offer.AttributePriceDetails(offerId, InplaceEditor.Offer.Field.Price))); } float priceWithCustomOptions = CalculateProductPrice(productPrice, 0, null, CustomOptionsService.DeserializeFromXml(customOptions)); var priceWithDiscount = CalculateProductPrice(productPrice, discount, customerGroup, CustomOptionsService.DeserializeFromXml(customOptions)); if (discount == 0 || !showDiscount) { return(String.Format("<div class=\'price-wrap inplace-indicator-offset {1}\'>{0}</div>", GetStringPriceInplace(priceWithDiscount, InplaceEditor.Offer.Field.Price, offerId), !SettingsMain.EnableInplace ? "inplace-indicator-offset-off" : "")); } var groupDiscount = customerGroup.CustomerGroupId == 0 ? 0 : customerGroup.GroupDiscount; var finalDiscount = Math.Max(discount, groupDiscount); return (String.Format( "<div class=\"price-old inplace-indicator-offset\">{0}</div><div class=\"price-wrap\">{1}</div><div class=\"price-benefit\">{2} {3} {4} {5}% </div>", GetStringPriceInplace(priceWithCustomOptions, InplaceEditor.Offer.Field.Price, offerId), GetStringPrice(priceWithDiscount, isMainPrice: true), Resource.Client_Catalog_Discount_Benefit, GetStringPrice(priceWithCustomOptions - priceWithDiscount), Resource.Client_Catalog_Discount_Or, FormatPriceInvariant(finalDiscount))); }
public ActionResult Edit(CustomerGroup customerGroup, HttpPostedFileBase fileupload) { if (ModelState.IsValid) { #region Upload and resize image if needed if (fileupload != null) { string filename = Path.GetFileName(fileupload.FileName); string newFilename = Guid.NewGuid().ToString().Replace("-", string.Empty) + Path.GetExtension(filename); string newFilenameUrl = "/Uploads/CustomerGroup/" + newFilename; string physicalFilename = Server.MapPath(newFilenameUrl); fileupload.SaveAs(physicalFilename); customerGroup.ImageUrl = newFilenameUrl; } #endregion customerGroup.IsDeleted = false; db.Entry(customerGroup).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(customerGroup)); }
/// <summary> /// 修改客户分组 /// </summary> /// <param name="id">Id</param> /// <param name="name">分组名称</param> /// <param name="remark">备注</param> /// <param name="mender">修改人</param> public void Update(string id, string name, string remark, string mender) { using (DbConnection conn = DbHelper.CreateConnection()) { DbTransaction trans = null; try { conn.Open(); trans = conn.BeginTransaction(); if (trans == null) { throw new ArgumentNullException("DbTransaction"); } if (this.customerGroupRepository.HasSameName(trans, id, name)) { throw new EasySoftException(BusinessResource.Customer_ExistsSameGroupName); } CustomerGroup entity = this.Select(trans, id); entity.Update(name, remark, mender); this.customerGroupRepository.Update(trans, entity); trans.Commit(); } catch { if (trans != null) { trans.Rollback(); } throw; } } }
public void RequestCarTest(double gX, double gY, double eX, double eY, DirectionCar direction) { var road = new Road(new Vector(0, 50), new Vector(100, 50), 10, 100); var garage1 = new Garage(new Vector(80, 20), 10); var garage2 = new Garage(new Vector(20, 80), 10); var building = new Building(new Vector(gX, gY), 1); var city = new CityBuilder() .Road(road) .Building(garage1) .Building(garage2) .Building(building) .Build(); var group = new CustomerGroup(1, building, building); GPSSystem.RequestCar(new Destination { Road = road, Location = building.Location }, group); Assert.IsNotEmpty(city.Cars); var car = city.Cars[0]; Assert.AreEqual(eX, car.Location.X, 0.5); Assert.AreEqual(eY, car.Location.Y, 0.5); Assert.AreEqual(direction, car.Direction); }
public CustomerGroup CreateCustomerGroup() { CustomerGroup customerGroup = this.customerGroupFixture.CreateCustomerGroup(); this.customerGroupFixture.CustomerGroupsToDelete.Add(customerGroup); return(customerGroup); }
public async Task <IActionResult> Edit(int id, [Bind("ID,Name,Description,Rabatt")] CustomerGroup customerGroup) { if (id != customerGroup.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(customerGroup); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CustomerGroupExists(customerGroup.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(customerGroup)); }
/// <summary> /// Request a car /// </summary> /// <param name="destination">destination the group want to go</param> /// <param name="group">group who request a car</param> public static void RequestCar(Destination destination, CustomerGroup group) { App.Console?.Print( $"Group #{group.GetHashCode()} has requested a car from {group.Location} to {destination.Location}" ); // Look to nearest Garage. var city = City.Instance; var garages = city.Buildings .FindAll(building => building is Garage) .Select(building => (Garage)building) .Where(g => g.AvailableCars > 0) .ToList(); Garage nearestGarage = null; var nearestDistance = double.MaxValue; foreach (var garage in garages) { var tempDistance = MathUtil.Distance(group.Location, garage.Location); if (!(tempDistance < nearestDistance)) { continue; } nearestGarage = garage; nearestDistance = tempDistance; } nearestGarage?.SpawnCar(CityController.CAR_ID++, new Destination { Location = group.Location, Road = NearestRoad(group.Location) }); }
public int deleteCustomerGroup(int groupId) { var message = 0; var data = new CustomerGroup(); if (groupId > 0) { data = db.CustomerGroups.Where(x => x.Id == groupId).FirstOrDefault(); } if (data != null) { data.IsActive = false; } var obj = db.CustomerGroupUsers.Where(x => x.CustomerGroupId == groupId).ToList(); if (obj != null) { foreach (var item in obj) { item.IsActive = false; message = 1; } } try { db.SaveChanges(); } catch (Exception e) { Console.Write(e.Message); } return(message); }
public int Post(CustomerGroup customerGroup) { using (DbContext dBContext = new DbContext())//doi tuong khoi tao trong khoi using se tu dong huy { return(dBContext.InsertCustomerGroup(customerGroup)); } }
/// <summary> /// Get the order of Customers with the algorithm Nearest Neighbour /// </summary> /// <param name="start"></param> /// <param name="customerGroups"></param> /// <returns></returns> public static List <CustomerGroup> CalculateOrderCustomers(Vector start, List <CustomerGroup> customerGroups) { var orderOfCustomers = new List <CustomerGroup>(); var customerLocations = customerGroups.Select(c => c.Location).ToList(); var currentLocation = start; // do this for every customerGroup for (int i = 0; i < customerGroups.Count; i++) { double minLength = double.PositiveInfinity; CustomerGroup customerToAddToOrder = null; // find the customergroup with the shortest distance from the currentLocation foreach (var location in customerLocations) { var calculatedDistance = MathUtil.Distance(currentLocation, location); if (calculatedDistance < minLength) { minLength = calculatedDistance; customerToAddToOrder = customerGroups[i]; } } // set de current location to the customergroup location and add the customergroup to the order currentLocation = customerToAddToOrder.Location; orderOfCustomers.Add(customerToAddToOrder); } return(orderOfCustomers); }
private CMS.AMS.Models.CustomerGroup CreateCustomerGroup() { CMS.AMS.Models.CustomerGroup NewCustGroup = null; try { bool saved = m_CustGroup.CreateUpdateCustomerGroup(new CustomerGroup { Name = Logix.TrimAll(functioninput.Text) }); if (saved) { NewCustGroup = new CustomerGroup(); NewCustGroup = m_CustGroup.GetCustomerGroupByName(Logix.TrimAll(functioninput.Text)); if (MyCommon.LRTadoConn.State == ConnectionState.Closed) { MyCommon.Open_LogixRT(); } MyCommon.Activity_Log(7, NewCustGroup.CustomerGroupID, CurrentUser.AdminUser.ID, Copient.PhraseLib.Lookup("history.cgroup-create", LanguageID)); } } catch (Exception err) { ScriptManager.RegisterStartupScript(UpdatePanelMain, UpdatePanelMain.GetType(), "AlertMessage", " AlertMessage('" + err.Message + "');", true); } finally { MyCommon.Close_LogixRT(); } return(NewCustGroup); }
public IActionResult Post([FromBody] CustomerGroupForm model) { try { if (ModelState.IsValid) { var customergroup = new CustomerGroup { Name = model.Name, Description = model.Description, IsActive = model.IsActive }; _customergroupRepository.Add(customergroup); _customergroupRepository.SaveChanges(); return(Ok()); } } catch (DbUpdateException ex) { if (ExceptionHelper.IsUniqueConstraintViolation(ex)) { ModelState.AddModelError("Name", $"The Name '{model.Name}' is already in use, please enter a different name."); return(new BadRequestObjectResult(ModelState)); } throw; } return(new BadRequestObjectResult(ModelState)); }
public int InsertGroupCustomer(CustomerGroup customerGroup) { var customerDL = new CustomerDL(); //kiem tra loi trung ma return(customerDL.Post(customerGroup)); }
/// <summary> /// Calculates the path to the customergroup using Dijkstra algorithm /// </summary> /// <param name="start">start path</param> /// <param name="group">group customers</param> /// <returns>list with the roads to take</returns> public static List <Road> CalculateRouteToCustomerGroup(Vector start, CustomerGroup group) { var startRoad = GPSSystem.NearestRoad(start); var endRoad = GPSSystem.NearestRoad(group.Location); var hitEnd = false; var listPaths = new List <Path>(); // if the starroad equals to the endRoad if (startRoad == endRoad) { return(new List <Road> { startRoad }); } ; //add the first two intersections of the startRoad to the PathList; foreach (var item in GPSSystem.FindIntersectionsRoad(startRoad)) { listPaths.Add(new Path(start, group.Location, item)); } // loop until the end is found while (hitEnd == false) { var newListPaths = new List <Path>(); foreach (var path in listPaths) { // new found intersections var lastIntersectionOfPath = path.Intersections.Last(); var newFoundIntersections = GPSSystem.FindNextIntersections(lastIntersectionOfPath); // add the path of every new intersetion to the new ListPath foreach (var intersection in newFoundIntersections) { var intersections = new List <Intersection>(path.Intersections); intersections.Add(intersection); var newPath = new Path(start, group.Location, intersection); newListPaths.Add(newPath); // check if endLocation is between these intersections if ((endRoad.End == intersection.Location || endRoad.Start == intersection.Location) && (endRoad.End == lastIntersectionOfPath.Location || endRoad.Start == lastIntersectionOfPath.Location)) { return(newPath.PathToRoadList()); } else { throw new Exception("roads are not horizontal or vertical"); } } } // set the new list listPaths = newListPaths; } return(null); }
public async Task <bool> Handle(InstallPermissionsCommand request, CancellationToken cancellationToken) { //install new permissions var permissions = request.PermissionProvider.GetPermissions(); foreach (var permission in permissions) { var permission1 = await _permissionService.GetPermissionBySystemName(permission.SystemName); if (permission1 == null) { //new permission (install it) permission1 = new Permission { Name = permission.Name, SystemName = permission.SystemName, Area = permission.Area, Category = permission.Category, Actions = permission.Actions }; //default customer group mappings var defaultPermissions = request.PermissionProvider.GetDefaultPermissions(); foreach (var defaultPermission in defaultPermissions) { var customerGroup = await _groupService.GetCustomerGroupBySystemName(defaultPermission.CustomerGroupSystemName); if (customerGroup == null) { //new role (save it) customerGroup = new CustomerGroup { Name = defaultPermission.CustomerGroupSystemName, Active = true, SystemName = defaultPermission.CustomerGroupSystemName }; await _groupService.InsertCustomerGroup(customerGroup); } var defaultMappingProvided = (from p in defaultPermission.Permissions where p.SystemName == permission1.SystemName select p).Any(); if (defaultMappingProvided) { permission1.CustomerGroups.Add(customerGroup.Id); } } //save new permission await _permissionService.InsertPermission(permission1); //save localization await permission1.SaveTranslationPermissionName(_translationService, _languageService); } } return(true); }
public CustomerGroup CreateCustomerGroupWithCustomFields() { CustomerGroupDraft draft = this.CreateCustomerGroupDraftWithCustomFields(); IClient commerceToolsClient = this.GetService <IClient>(); CustomerGroup customerGroup = commerceToolsClient.ExecuteAsync(new CreateCommand <CustomerGroup>(draft)).Result; return(customerGroup); }
public void EntityLoadByPrimaryKeyChar() { CustomerGroup cg = new CustomerGroup(); cg.es.Connection.Name = "ForeignKeyTest"; Assert.IsTrue(cg.LoadByPrimaryKey("05001")); }
public ActionResult Edit(string id, int page = 1) { CustomerGroup entity = this.customerGroupService.Select(id); CustomerGroupEditModel model = new CustomerGroupEditModel(entity); model.PageIndex = page; return(View(model)); }
public static CustomerGroup CreateCustomerGroup(string dataAreaId, string customerGroupId) { CustomerGroup customerGroup = new CustomerGroup(); customerGroup.dataAreaId = dataAreaId; customerGroup.CustomerGroupId = customerGroupId; return(customerGroup); }
/// <summary> /// Thêm mới nhóm khách hàng /// </summary> /// <param name="customerGroup"></param> /// <returns></returns> /// CreatedBy KDLong 06/05/2021 public int InsertCustomerGroup(CustomerGroup customerGroup) { using (dbConnection = new MySqlConnection(connectionString)) { var rowsAffect = dbConnection.Execute($"Proc_InsertCustomerGroup", param: customerGroup, commandType: CommandType.StoredProcedure); return(rowsAffect); } }
public static CustomerGroupDto MappingDto(this CustomerGroup customerGroup) { return(new CustomerGroupDto { Id = customerGroup.Id, Name = customerGroup.Name, }); }
public CustomerGroupEntity Update(EmployeeEntity EmployeeEntity, Guid CustomerGroupId, CustomerGroupEntity CustomerGroupEntity) { CustomerGroupEntity.Id = CustomerGroupId; CustomerGroup CustomerGroup = new CustomerGroup(CustomerGroupEntity); UnitOfWork.CustomerGroupRepository.AddOrUpdate(CustomerGroup); UnitOfWork.Complete(); return(Get(EmployeeEntity, CustomerGroup.Id)); }
protected void Page_PreRender(object sender, EventArgs e) { decimal discount = 0; if (grid.UpdatedRow != null && (decimal.TryParse(grid.UpdatedRow["GroupDiscount"].Replace("%", ""), out discount)) && (discount >= 0) && (discount < 100)) { int customerGroupId = 0; int.TryParse(grid.UpdatedRow["ID"], out customerGroupId); var customerGroup = new CustomerGroup { CustomerGroupId = customerGroupId, GroupName = grid.UpdatedRow["GroupName"], GroupDiscount = discount, OfferListId = CatalogService.DefaultOfferListId }; CustomerGroupService.UpdateCustomerGroup(customerGroup); } DataTable data = _paging.PageItems; while (data.Rows.Count < 1 && _paging.CurrentPageIndex > 1) { _paging.CurrentPageIndex--; data = _paging.PageItems; } var clmn = new DataColumn("IsSelected", typeof(bool)) { DefaultValue = _inverseSelection }; data.Columns.Add(clmn); if ((_selectionFilter != null) && (_selectionFilter.Values != null)) { for (int i = 0; i <= data.Rows.Count - 1; i++) { int intIndex = i; if (Array.Exists(_selectionFilter.Values, c => c == data.Rows[intIndex]["ID"].ToString())) { data.Rows[i]["IsSelected"] = !_inverseSelection; } } } if (data.Rows.Count < 1) { goToPage.Visible = false; } grid.DataSource = data; grid.DataBind(); pageNumberer.PageCount = _paging.PageCount; lblFound.Text = _paging.TotalRowsCount.ToString(); }
public static CustomerGroup CreateCustomerGroup(int ID, string customerGroupName, bool discontinued, byte[] rowVersion) { CustomerGroup customerGroup = new CustomerGroup(); customerGroup.Id = ID; customerGroup.CustomerGroupName = customerGroupName; customerGroup.Discontinued = discontinued; customerGroup.RowVersion = rowVersion; return customerGroup; }
public void AddToCustomerGroups(CustomerGroup customerGroup) { base.AddObject("CustomerGroups", customerGroup); }