public IHttpActionResult Post(ServiceGroupModel baseRequest) { baseRequest.OrganizationID = SecurityHelper.CurrentPrincipal.OrgId; var response = service.SaveServiceGroup(baseRequest); return(Ok(response)); }
public ServiceOperator(SocketMessage message) { if (!(message.Body is ServiceGroupModel serviceGroup)) { throw new ArgumentException(nameof(message.Body)); } ServiceGroup = serviceGroup; }
private void Load() { if (_serviceGroups == null) { //数据库检索 _serviceGroups = new ObservableCollection <ServiceGroupModel>(); using (DBConnect connect = new DBFactory().GetPostgreSQLDBConnect().StartConnect()) { var list = connect.FindAll <DBModels.PostgreSQL.ServiceGroup, string>(m => m.ShowIndex); foreach (var item in list) { ServiceGroupModel model = new ServiceGroupModel(); ModelHelper.CopyModel(model, item); _serviceGroups.Add(model); } } } }
//private static ServiceListModel _services = null; //public void LoadData(object sender, InitiateEventArgs e) //{ // Load(); //} //public void Subscribe(MasterDataInitiater evenSource) //{ // evenSource.InitiateEvent += new InitiateEventHandler(LoadData); // evenSource.ActionEvent += new Action<object, InitiateEventArgs>(LoadData); //} //public void UnSubscribe(MasterDataInitiater evenSource) //{ // evenSource.InitiateEvent -= new InitiateEventHandler(LoadData); // evenSource.ActionEvent -= new Action<object, InitiateEventArgs>(LoadData); //} public ServiceListModel GetAllServices(string salongCode) { //数据库检索 ServiceListModel _services = new ServiceListModel(); using (var context = new ApplicationDbContext()) { _services.ServiceGroups = new List <ServiceGroupModel>(); var list1 = context.ServiceGroups.OrderBy(m => m.ShowIndex).ToList(); foreach (var item in list1) { ServiceGroupModel model = new ServiceGroupModel(); ModelHelper.CopyModel(model, item); _services.ServiceGroups.Add(model); } _services.Services = new Dictionary <string, List <ServiceModel> >(); var list2 = context.SalonServices.Where(s => s.SalonCode == salongCode).Include(s => s.Service).ToList(); foreach (var item in _services.ServiceGroups) { var services = new List <ServiceModel>(); var list3 = list2.Select(s => s.Service).Where(m => m.GroupCode == item.Code).ToList(); foreach (var item1 in list3) { ServiceModel model = new ServiceModel(); ModelHelper.CopyModel(model, item1); services.Add(model); } if (services.Count > 0) { _services.Services.Add(item.Code, services); item.IsShow = true; } } } return(_services); //Load(); //return _services; }
public BaseResponse <ServiceGroupModel> SaveServiceGroup(ServiceGroupModel request) { var response = new BaseResponse <ServiceGroupModel>(); Action <DC_ServiceGroup> SaveChildren = (parent) => { if (request.GroupItems != null) { parent.DC_SerGrpSerIt.Clear(); request.GroupItems.ForEach(item => { var serGrpSerIt = new DC_SerGrpSerIt(); serGrpSerIt.ServiceItemID = item.ServiceItemID; serGrpSerIt.ServiceTimes = item.ServiceTimes.Value; parent.DC_SerGrpSerIt.Add(serGrpSerIt); }); } }; var model = unitOfWork.GetRepository <DC_ServiceGroup>().dbSet.FirstOrDefault((q) => q.ServiceGroupID == request.ServiceGroupID); if (model == null) { model = Mapper.DynamicMap <DC_ServiceGroup>(request); SaveChildren(model); unitOfWork.GetRepository <DC_ServiceGroup>().Insert(model); } else { Mapper.DynamicMap(request, model); SaveChildren(model); unitOfWork.GetRepository <DC_ServiceGroup>().Update(model); } unitOfWork.Save(); Mapper.DynamicMap(model, request); response.Data = request; return(response); }