示例#1
0
        public CustomerGroupViewModel()
        {
            var cmp = Convert.ToInt32(App.Current.Properties["Company_Id"].ToString());

            SelectedCustomer = new CustomerModel();
            if (App.Current.Properties["Action"] == "Edit")
            {
                CreatVisible          = "Collapsed";
                UpdVisible            = "Visible";
                SelectedCustomerGroup = App.Current.Properties["CustomerGroupEdit"] as CustomerGroupModel;
                //GetGodowns(COMPANY_ID);
                App.Current.Properties["Action"] = "";
            }
            else if (App.Current.Properties["Action"] == "View")
            {
                SelectedCustomerGroup            = App.Current.Properties["CustomerGroupView"] as CustomerGroupModel;
                App.Current.Properties["Action"] = "";
            }
            else
            {
                UpdVisible            = "Collapsed";
                CreatVisible          = "Visible";
                SelectedCustomerGroup = new CustomerGroupModel();
                GetCustomerGroup(cmp);
            }
        }
示例#2
0
        public virtual CustomerGroupModel PrepareCustomerGroupModel()
        {
            var model = new CustomerGroupModel();

            //default values
            model.Active = true;
            return(model);
        }
示例#3
0
        public virtual async Task <CustomerGroup> InsertCustomerGroupModel(CustomerGroupModel model)
        {
            var customerGroup = model.ToEntity();
            await _groupService.InsertCustomerGroup(customerGroup);

            //activity log
            await _customerActivityService.InsertActivity("AddNewCustomerGroup", customerGroup.Id, _translationService.GetResource("ActivityLog.AddNewCustomerGroup"), customerGroup.Name);

            return(customerGroup);
        }
示例#4
0
        void AddGroupToGrid(Backend.Objects.CustomerGroup customerGroup)
        {
            //Fill Grid [ GroupsGrid ] With Group
            CustomerGroupModel customerGroupModel = new CustomerGroupModel
            {
                OnDelete = OnDeleteGroup,
                Group    = customerGroup
            };

            //Add To Grid
            GroupsGrid.Controls.Add(customerGroupModel);
        }
示例#5
0
        public async Task <IActionResult> Create(CustomerGroupModel model, bool continueEditing)
        {
            if (ModelState.IsValid)
            {
                var customerGroup = await _customerGroupViewModelService.InsertCustomerGroupModel(model);

                Success(_translationService.GetResource("Admin.Customers.CustomerGroups.Added"));
                return(continueEditing ? RedirectToAction("Edit", new { id = customerGroup.Id }) : RedirectToAction("List"));
            }
            //If we got this far, something failed, redisplay form
            return(View(model));
        }
示例#6
0
        public Task <AddNewCustomerGroupResponse> addNewCustomerGroup(AddNewCustomerGroupRequest request)
        {
            AddNewCustomerGroupCommand command = new AddNewCustomerGroupCommand(request.Name);
            Task <object> CustomerGroup        = (Task <object>)Bus.SendCommand(command);
            //RabbitMQBus.Publish(command);
            AddNewCustomerGroupResponse response = new AddNewCustomerGroupResponse();

            response = Common <AddNewCustomerGroupResponse> .checkHasNotification(_notifications, response);

            if (response.Success)
            {
                CustomerGroupModel CustomerGroupModel = (CustomerGroupModel)CustomerGroup.Result;
                response.Data = CustomerGroupModel.ID;
            }
            return(Task.FromResult(response));
        }
示例#7
0
 public Task <object> Handle(AddNewCustomerGroupCommand command, CancellationToken cancellationToken)
 {
     Entities.CustomerGroup u = new Entities.CustomerGroup(null, new Name(command.Name));
     if (!command.IsValid())
     {
         NotifyValidationErrors(command);
     }
     else
     {
         CustomerGroupModel model = _CustomerGroupRepository.Add(u);
         if (model != null)
         {
             return(Task.FromResult(model as object));
         }
         _bus.RaiseEvent(new DomainNotification("CustomerGroup", "Server error", NotificationCode.Error));
     }
     return(Task.FromResult(null as object));
 }
        public async Task <IActionResult> Edit(CustomerGroupModel model)
        {
            if (ModelState.IsValid)
            {
                var result = await _customerGroupService.Update(_mapper.Map <CustomerGroupModel, UpdateCustomerGroupRequest>(model));

                if (result.IsSuccess)
                {
                    TempData["Update"] = result.ToJson();
                    return(RedirectToAction("Index",
                                            "CustomerGroup"));
                }

                ModelState.AddModelError("",
                                         result.Message);
            }

            return(View(model));
        }
示例#9
0
        public HttpResponseMessage GetConsultantsByGroup(CustomerGroupModel model)
        {
            if (ModelState.IsValid)
            {
                var criteria = new GroupIdQueryParameters
                {
                    GroupId  = model.g,
                    Page     = model.i,
                    PageSize = model.s,
                };

                var client    = _clientFactory.GetCustomersQueryServiceClient();
                var customers = client.GetCustomersByGroupId(criteria);
                var json      = JsonConvert.SerializeObject(customers.Data, new IsoDateTimeConverter());

                return ApiHelpers.JsonResponseMessage(json);
            }

            throw ApiHelpers.ServerError(ModelState);
        }
示例#10
0
        public async Task <IActionResult> Edit(CustomerGroupModel model, bool continueEditing)
        {
            var customerGroup = await _groupService.GetCustomerGroupById(model.Id);

            if (customerGroup == null)
            {
                //No customer group found with the specified id
                return(RedirectToAction("List"));
            }

            try
            {
                if (ModelState.IsValid)
                {
                    if (customerGroup.IsSystem && !model.Active)
                    {
                        throw new GrandException(_translationService.GetResource("Admin.Customers.CustomerGroups.Fields.Active.CantEditSystem"));
                    }

                    if (customerGroup.IsSystem && !customerGroup.SystemName.Equals(model.SystemName, StringComparison.OrdinalIgnoreCase))
                    {
                        throw new GrandException(_translationService.GetResource("Admin.Customers.CustomerGroups.Fields.SystemName.CantEditSystem"));
                    }

                    customerGroup = await _customerGroupViewModelService.UpdateCustomerGroupModel(customerGroup, model);

                    Success(_translationService.GetResource("Admin.Customers.CustomerGroups.Updated"));
                    return(continueEditing ? RedirectToAction("Edit", new { id = customerGroup.Id }) : RedirectToAction("List"));
                }

                //If we got this far, something failed, redisplay form
                return(View(model));
            }
            catch (Exception exc)
            {
                Error(exc);
                return(RedirectToAction("Edit", new { id = customerGroup.Id }));
            }
        }
示例#11
0
        public HttpResponseMessage CustomerGroupAdd(CustomerGroupModel _CustomerGroupModel)
        {
            try
            {
                bool conn = false;
                conn = db.Database.Exists();
                if (!conn)
                {
                    ConnectionTools.changeToLocalDB(db);
                    conn = db.Database.Exists();
                }

                if (conn)
                {
                    TBL_CUSTOMER_GROUP Customer = new TBL_CUSTOMER_GROUP();
                    Customer.COMPANY_ID  = _CustomerGroupModel.COMPANY_ID;
                    Customer.DESCRIPTION = _CustomerGroupModel.DESCRIPTION;
                    Customer.NAME        = _CustomerGroupModel.NAME;
                    Customer.IS_DELETE   = false;
                    db.TBL_CUSTOMER_GROUP.Add(Customer);
                    db.SaveChanges();
                    return(Request.CreateResponse(HttpStatusCode.OK, "Success"));
                }
                else
                {
                    return(Request.CreateResponse(HttpStatusCode.ExpectationFailed));
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                ConnectionTools.ChangeToRemoteDB(db);
            }
        }
示例#12
0
        public HttpResponseMessage CustomerGroupUpdate(CustomerGroupModel _CustomerGroupModel)
        {
            try
            {
                bool conn = false;
                conn = db.Database.Exists();
                if (!conn)
                {
                    ConnectionTools.changeToLocalDB(db);
                    conn = db.Database.Exists();
                }

                if (conn)
                {
                    var str = (from a in db.TBL_CUSTOMER_GROUP where a.COMPANY_ID == _CustomerGroupModel.COMPANY_ID select a).FirstOrDefault();
                    str.COMPANY_ID  = _CustomerGroupModel.COMPANY_ID;
                    str.DESCRIPTION = _CustomerGroupModel.DESCRIPTION;
                    str.NAME        = _CustomerGroupModel.NAME;
                    str.IS_DELETE   = false;
                    db.SaveChanges();
                    return(Request.CreateResponse(HttpStatusCode.OK, "Success"));
                }
                else
                {
                    return(Request.CreateResponse(HttpStatusCode.ExpectationFailed));
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                ConnectionTools.ChangeToRemoteDB(db);
            }
        }
示例#13
0
        public virtual async Task <CustomerGroup> UpdateCustomerGroupModel(CustomerGroup customerGroup, CustomerGroupModel model)
        {
            customerGroup = model.ToEntity(customerGroup);
            await _groupService.UpdateCustomerGroup(customerGroup);

            //activity log
            await _customerActivityService.InsertActivity("EditCustomerGroup", customerGroup.Id, _translationService.GetResource("ActivityLog.EditCustomerGroup"), customerGroup.Name);

            return(customerGroup);
        }
示例#14
0
        public JsonResult GetList()
        {
            var model = new CustomerGroupModel();

            return(Json(model.GetList(), JsonRequestBehavior.AllowGet));
        }
 public static CustomerGroup ToEntity(this CustomerGroupModel model, CustomerGroup destination)
 {
     return(model.MapTo(destination));
 }
 public static CustomerGroup ToEntity(this CustomerGroupModel model)
 {
     return(model.MapTo <CustomerGroupModel, CustomerGroup>());
 }