当前位置: 首页>>代码示例>>C#>>正文


C# DTO.Empty方法代码示例

本文整理汇总了C#中DTO.Empty方法的典型用法代码示例。如果您正苦于以下问题:C# DTO.Empty方法的具体用法?C# DTO.Empty怎么用?C# DTO.Empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DTO的用法示例。


在下文中一共展示了DTO.Empty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: EditAdditionalService

        public async Task<DTO.AdditionalService> EditAdditionalService(DTO.AdditionalService source)
        {
            return await Task.Run(() =>
            {
                CheckPermission(UserRole.Administrator, AdministratorPermissions.AdditionalServices);

                using (var session = SessionProvider.OpenSession())
                using (var transaction = session.BeginTransaction())
                {
                    AdditionalService additionalService;

                    if (!source.Empty())
                    {
                        var additionalServiceId = source.Id;
                        additionalService = session.Get<AdditionalService>(additionalServiceId);
                        if (additionalService == null)
                        {
                            throw new FaultException<ObjectNotFoundFault>(new ObjectNotFoundFault(additionalServiceId), string.Format("Дополнительная услуга [{0}] не найдена", additionalServiceId));
                        }
                    }
                    else
                    {
                        additionalService = new AdditionalService();
                    }

                    additionalService.Name = source.Name;
                    additionalService.Price = source.Price;
                    additionalService.Measure = source.Measure;

                    var errors = additionalService.Validate();
                    if (errors.Length > 0)
                    {
                        throw new FaultException(errors.First().Message);
                    }

                    session.Save(additionalService);
                    transaction.Commit();

                    return Mapper.Map<AdditionalService, DTO.AdditionalService>(additionalService);
                }
            });
        }
开发者ID:breslavsky,项目名称:queue,代码行数:42,代码来源:AdditionalService.cs

示例2: EditOffice

        public async Task<DTO.Office> EditOffice(DTO.Office source)
        {
            return await Task.Run(() =>
            {
                CheckPermission(UserRole.Administrator, AdministratorPermissions.Offices);

                using (var session = SessionProvider.OpenSession())
                using (var transaction = session.BeginTransaction())
                {
                    Office office;

                    if (!source.Empty())
                    {
                        var officeId = source.Id;
                        office = session.Get<Office>(officeId);
                        if (office == null)
                        {
                            throw new FaultException<ObjectNotFoundFault>(new ObjectNotFoundFault(officeId), string.Format("Филиал [{0}] не найден", officeId));
                        }
                    }
                    else
                    {
                        office = new Office();
                    }

                    office.Name = source.Name;
                    office.Endpoint = source.Endpoint;
                    office.SessionId = source.SessionId;

                    var errors = office.Validate();
                    if (errors.Length > 0)
                    {
                        throw new FaultException(errors.First().Message);
                    }

                    session.Save(office);
                    transaction.Commit();

                    return Mapper.Map<Office, DTO.Office>(office);
                }
            });
        }
开发者ID:breslavsky,项目名称:queue,代码行数:42,代码来源:Offices.cs

示例3: EditLifeSituation

        public async Task<DTO.LifeSituation> EditLifeSituation(DTO.LifeSituation source)
        {
            return await Task.Run(() =>
            {
                CheckPermission(UserRole.Administrator, AdministratorPermissions.LifeSituations);

                using (var session = SessionProvider.OpenSession())
                using (var transaction = session.BeginTransaction())
                {
                    LifeSituation lifeSituation;

                    if (!source.Empty())
                    {
                        var lifeSituationId = source.Id;
                        lifeSituation = session.Get<LifeSituation>(lifeSituationId);
                        if (lifeSituation == null)
                        {
                            throw new FaultException<ObjectNotFoundFault>(new ObjectNotFoundFault(lifeSituationId),
                                string.Format("Жизненная ситуация [{0}] не найдена", lifeSituationId));
                        }
                    }
                    else
                    {
                        lifeSituation = new LifeSituation();
                    }

                    lifeSituation.IsActive = source.IsActive;
                    lifeSituation.Code = source.Code;
                    lifeSituation.Name = source.Name;
                    lifeSituation.Comment = source.Comment;
                    lifeSituation.Description = source.Description;
                    lifeSituation.Color = source.Color;
                    lifeSituation.FontSize = source.FontSize;

                    if (source.LifeSituationGroup != null)
                    {
                        Guid groupId = source.LifeSituationGroup.Id;

                        var group = session.Get<LifeSituationGroup>(groupId);
                        if (group == null)
                        {
                            throw new FaultException<ObjectNotFoundFault>(new ObjectNotFoundFault(groupId),
                                string.Format("Группа жизненной ситуации [{0}] не найдена", groupId));
                        }

                        lifeSituation.LifeSituationGroup = group;
                    }
                    else
                    {
                        lifeSituation.LifeSituationGroup = null;
                    }

                    if (source.Service != null)
                    {
                        Guid serviceId = source.Service.Id;

                        var service = session.Get<Service>(serviceId);
                        if (service == null)
                        {
                            throw new FaultException<ObjectNotFoundFault>(new ObjectNotFoundFault(serviceId),
                                string.Format("Услуга [{0}] не найдена", serviceId));
                        }

                        lifeSituation.Service = service;
                    }
                    else
                    {
                        lifeSituation.Service = null;
                    }

                    var errors = lifeSituation.Validate();
                    if (errors.Length > 0)
                    {
                        throw new FaultException(errors.First().Message);
                    }

                    session.Save(lifeSituation);

                    var todayQueuePlan = QueueInstance.TodayQueuePlan;
                    using (var locker = todayQueuePlan.WriteLock())
                    {
                        transaction.Commit();

                        todayQueuePlan.Put(lifeSituation);
                    }

                    return Mapper.Map<LifeSituation, DTO.LifeSituation>(lifeSituation);
                }
            });
        }
开发者ID:breslavsky,项目名称:queue,代码行数:90,代码来源:LifeSituationService.cs

示例4: EditServiceGroup

        public async Task<DTO.ServiceGroup> EditServiceGroup(DTO.ServiceGroup source)
        {
            return await Task.Run(() =>
            {
                CheckPermission(UserRole.Administrator, AdministratorPermissions.Services);

                using (var session = SessionProvider.OpenSession())
                using (var transaction = session.BeginTransaction())
                {
                    ServiceGroup serviceGroup;

                    if (!source.Empty())
                    {
                        var serviceGroupId = source.Id;
                        serviceGroup = session.Get<ServiceGroup>(serviceGroupId);
                        if (serviceGroup == null)
                        {
                            throw new FaultException<ObjectNotFoundFault>(new ObjectNotFoundFault(serviceGroupId),
                                string.Format("Группа услуг [{0}] не найдена", serviceGroupId));
                        }
                    }
                    else
                    {
                        serviceGroup = new ServiceGroup();
                    }

                    serviceGroup.IsActive = source.IsActive;
                    serviceGroup.Code = source.Code;
                    serviceGroup.Name = source.Name;
                    serviceGroup.Comment = source.Comment;
                    serviceGroup.Description = source.Description;
                    serviceGroup.Columns = source.Columns;
                    serviceGroup.Rows = source.Rows;
                    serviceGroup.Color = source.Color;
                    serviceGroup.FontSize = source.FontSize;

                    if (source.ParentGroup != null)
                    {
                        Guid parentGroupId = source.ParentGroup.Id;

                        ServiceGroup parentGroup = session.Get<ServiceGroup>(parentGroupId);
                        if (parentGroup == null)
                        {
                            throw new FaultException<ObjectNotFoundFault>(new ObjectNotFoundFault(parentGroupId),
                                string.Format("Группа услуг [{0}] не найдена", parentGroupId));
                        }

                        serviceGroup.ParentGroup = parentGroup;
                    }
                    else
                    {
                        serviceGroup.ParentGroup = null;
                    }

                    var errors = serviceGroup.Validate();
                    if (errors.Length > 0)
                    {
                        throw new FaultException(errors.First().Message);
                    }

                    session.Save(serviceGroup);

                    var todayQueuePlan = QueueInstance.TodayQueuePlan;
                    using (var locker = todayQueuePlan.WriteLock())
                    {
                        transaction.Commit();

                        todayQueuePlan.Put(serviceGroup);
                    }

                    return Mapper.Map<ServiceGroup, DTO.ServiceGroup>(serviceGroup);
                }
            });
        }
开发者ID:breslavsky,项目名称:queue,代码行数:74,代码来源:ServiceGroups.cs

示例5: EditServiceParameterNumber

        public async Task<DTO.ServiceParameterNumber> EditServiceParameterNumber(DTO.ServiceParameterNumber source)
        {
            return await Task.Run(() =>
            {
                CheckPermission(UserRole.Administrator, AdministratorPermissions.Services);

                using (var session = SessionProvider.OpenSession())
                using (var transaction = session.BeginTransaction())
                {
                    var parameterId = source.Id;

                    ServiceParameterNumber parameter;

                    if (!source.Empty())
                    {
                        parameter = session.Get<ServiceParameterNumber>(parameterId);
                        if (parameter == null)
                        {
                            throw new FaultException<ObjectNotFoundFault>(new ObjectNotFoundFault(parameterId),
                                string.Format("Параметр услуги [{0}] не найден", parameterId));
                        }
                    }
                    else
                    {
                        parameter = new ServiceParameterNumber();
                    }

                    parameter.Name = source.Name;
                    parameter.ToolTip = source.ToolTip;
                    parameter.IsRequire = source.IsRequire;

                    if (source.Service != null)
                    {
                        Guid serviceId = source.Service.Id;

                        Service service = session.Get<Service>(serviceId);
                        if (service == null)
                        {
                            throw new FaultException<ObjectNotFoundFault>(new ObjectNotFoundFault(serviceId),
                                string.Format("Услуга [{0}] не найдена", serviceId));
                        }
                        parameter.Service = service;
                    }
                    else
                    {
                        parameter.Service = null;
                    }

                    var errors = parameter.Validate();
                    if (errors.Length > 0)
                    {
                        throw new FaultException(errors.First().Message);
                    }

                    session.Save(parameter);
                    transaction.Commit();

                    return Mapper.Map<ServiceParameterNumber, DTO.ServiceParameterNumber>(parameter);
                }
            });
        }
开发者ID:breslavsky,项目名称:queue,代码行数:61,代码来源:ServicesParameters.cs

示例6: EditService

        public async Task<DTO.Service> EditService(DTO.Service source)
        {
            return await Task.Run(() =>
            {
                CheckPermission(UserRole.Administrator, AdministratorPermissions.Services);

                using (var session = SessionProvider.OpenSession())
                using (var transaction = session.BeginTransaction())
                {
                    Service service;

                    if (!source.Empty())
                    {
                        var serviceId = source.Id;
                        service = session.Get<Service>(serviceId);
                        if (service == null)
                        {
                            throw new FaultException<ObjectNotFoundFault>(new ObjectNotFoundFault(serviceId), string.Format("Услуга [{0}] не найдена", serviceId));
                        }
                    }
                    else
                    {
                        service = new Service();
                    }

                    service.IsActive = source.IsActive;
                    service.Code = source.Code;
                    service.Priority = source.Priority;
                    service.Name = source.Name;
                    service.Comment = source.Comment;
                    service.Tags = source.Tags;
                    service.Description = source.Description;
                    service.Link = source.Link;
                    service.MaxSubjects = source.MaxSubjects;
                    service.MaxEarlyDays = source.MaxEarlyDays;
                    service.MaxClientRecalls = source.MaxClientRecalls;
                    service.IsPlanSubjects = source.IsPlanSubjects;
                    service.ClientRequire = source.ClientRequire;
                    service.ClientCallDelay = source.ClientCallDelay;
                    service.TimeIntervalRounding = source.TimeIntervalRounding;
                    service.IsUseType = source.IsUseType;
                    service.LiveRegistrator = source.LiveRegistrator;
                    service.EarlyRegistrator = source.EarlyRegistrator;
                    service.Color = source.Color;
                    service.FontSize = source.FontSize;

                    if (source.ServiceGroup != null)
                    {
                        Guid serviceGroupId = source.ServiceGroup.Id;

                        ServiceGroup serviceGroup = session.Get<ServiceGroup>(serviceGroupId);
                        if (serviceGroup == null)
                        {
                            throw new FaultException<ObjectNotFoundFault>(new ObjectNotFoundFault(serviceGroupId),
                                string.Format("Группа услуг [{0}] не найдена", serviceGroupId));
                        }

                        service.ServiceGroup = serviceGroup;
                    }
                    else
                    {
                        service.ServiceGroup = null;
                    }

                    var errors = service.Validate();
                    if (errors.Length > 0)
                    {
                        throw new FaultException(errors.First().Message);
                    }

                    session.Save(service);

                    var todayQueuePlan = QueueInstance.TodayQueuePlan;
                    using (var locker = todayQueuePlan.WriteLock())
                    {
                        transaction.Commit();

                        todayQueuePlan.Put(service);
                    }

                    return Mapper.Map<Service, DTO.Service>(service);
                }
            });
        }
开发者ID:breslavsky,项目名称:queue,代码行数:84,代码来源:Services.cs

示例7: EditAdministrator

        public async Task<DTO.Administrator> EditAdministrator(DTO.Administrator source)
        {
            return await Task.Run(() =>
            {
                CheckPermission(UserRole.Administrator, AdministratorPermissions.Users);

                using (var session = SessionProvider.OpenSession())
                using (var transaction = session.BeginTransaction())
                {
                    Administrator administrator;

                    if (!source.Empty())
                    {
                        var administratorId = source.Id;
                        administrator = session.Get<Administrator>(administratorId);
                        if (administrator == null)
                        {
                            throw new FaultException<ObjectNotFoundFault>(new ObjectNotFoundFault(administratorId),
                                string.Format("Администратор [{0}] не найден", administratorId));
                        }
                    }
                    else
                    {
                        administrator = new Administrator()
                        {
                            SessionId = Guid.NewGuid()
                        };
                    }

                    administrator.Surname = source.Surname;
                    administrator.Name = source.Name;
                    administrator.Patronymic = source.Patronymic;
                    administrator.Email = source.Email;
                    administrator.Mobile = source.Mobile;
                    administrator.IsActive = source.IsActive;
                    administrator.Permissions = source.Permissions;
                    administrator.IsMultisession = source.IsMultisession;

                    var errors = administrator.Validate();
                    if (errors.Length > 0)
                    {
                        throw new FaultException(errors.First().Message);
                    }

                    session.Save(administrator);

                    var todayQueuePlan = QueueInstance.TodayQueuePlan;
                    using (var locker = todayQueuePlan.WriteLock())
                    {
                        transaction.Commit();

                        todayQueuePlan.Put(administrator);
                    }

                    return Mapper.Map<Administrator, DTO.Administrator>(administrator);
                }
            });
        }
开发者ID:breslavsky,项目名称:queue,代码行数:58,代码来源:UserService.cs

示例8: EditOperator

        public async Task<DTO.Operator> EditOperator(DTO.Operator source)
        {
            return await Task.Run(() =>
            {
                CheckPermission(UserRole.Administrator, AdministratorPermissions.Users);

                using (var session = SessionProvider.OpenSession())
                using (var transaction = session.BeginTransaction())
                {
                    Operator queueOperator;

                    if (!source.Empty())
                    {
                        var operatorId = source.Id;
                        queueOperator = session.Get<Operator>(operatorId);
                        if (queueOperator == null)
                        {
                            throw new FaultException<ObjectNotFoundFault>(new ObjectNotFoundFault(operatorId),
                                string.Format("Оператор [{0}] не найден", operatorId));
                        }
                    }
                    else
                    {
                        queueOperator = new Operator()
                        {
                            SessionId = Guid.NewGuid()
                        };
                    }

                    queueOperator.Surname = source.Surname;
                    queueOperator.Name = source.Name;
                    queueOperator.Patronymic = source.Patronymic;
                    queueOperator.Email = source.Email;
                    queueOperator.Mobile = source.Mobile;
                    queueOperator.IsActive = source.IsActive;
                    queueOperator.Identity = source.Identity;
                    queueOperator.IsMultisession = source.IsMultisession;

                    if (source.Workplace != null)
                    {
                        Guid workplaceId = source.Workplace.Id;

                        Workplace workplace = session.Get<Workplace>(workplaceId);
                        if (workplace == null)
                        {
                            throw new FaultException<ObjectNotFoundFault>(new ObjectNotFoundFault(workplaceId),
                                string.Format("Рабочее место [{0}] не найдено", workplaceId));
                        }

                        queueOperator.Workplace = workplace;
                    }
                    else
                    {
                        queueOperator.Workplace = null;
                    }

                    var errors = queueOperator.Validate();
                    if (errors.Length > 0)
                    {
                        throw new FaultException(errors.First().Message);
                    }

                    session.Save(queueOperator);

                    var todayQueuePlan = QueueInstance.TodayQueuePlan;
                    using (var locker = todayQueuePlan.WriteLock())
                    {
                        transaction.Commit();

                        todayQueuePlan.Put(queueOperator);
                    }

                    return Mapper.Map<Operator, DTO.Operator>(queueOperator);
                }
            });
        }
开发者ID:breslavsky,项目名称:queue,代码行数:76,代码来源:UserService.cs

示例9: EditServiceRendering

        public async Task<DTO.ServiceRendering> EditServiceRendering(DTO.ServiceRendering source)
        {
            return await Task.Run(() =>
            {
                CheckPermission(UserRole.Administrator, AdministratorPermissions.Services);

                using (var session = SessionProvider.OpenSession())
                using (var transaction = session.BeginTransaction())
                {
                    ServiceRendering serviceRendering;

                    if (!source.Empty())
                    {
                        Guid serviceRenderingId = source.Id;
                        serviceRendering = session.Get<ServiceRendering>(serviceRenderingId);
                        if (serviceRendering == null)
                        {
                            throw new FaultException<ObjectNotFoundFault>(new ObjectNotFoundFault(serviceRenderingId),
                                string.Format("Обслуживание услуги [{0}] не найдено", serviceRenderingId));
                        }
                    }
                    else
                    {
                        serviceRendering = new ServiceRendering();
                    }

                    if (source.Schedule != null)
                    {
                        var scheduleId = source.Schedule.Id;

                        var schedule = session.Get<Schedule>(scheduleId);
                        if (schedule == null)
                        {
                            throw new FaultException<ObjectNotFoundFault>(new ObjectNotFoundFault(scheduleId),
                                string.Format("Расписание [{0}] не найдено", scheduleId));
                        }
                        serviceRendering.Schedule = schedule;
                    }
                    else
                    {
                        serviceRendering.Schedule = null;
                    }

                    if (source.Operator != null)
                    {
                        var operatorId = source.Operator.Id;

                        var queueOperator = session.Get<Operator>(operatorId);
                        if (queueOperator == null)
                        {
                            throw new FaultException<ObjectNotFoundFault>(new ObjectNotFoundFault(operatorId),
                                string.Format("Оператор [{0}] не найден", operatorId));
                        }
                        serviceRendering.Operator = queueOperator;
                    }
                    else
                    {
                        serviceRendering.Operator = null;
                    }

                    if (source.ServiceStep != null)
                    {
                        var serviceStepId = source.ServiceStep.Id;

                        var serviceStep = session.Get<ServiceStep>(serviceStepId);
                        if (serviceStep == null)
                        {
                            throw new FaultException<ObjectNotFoundFault>(new ObjectNotFoundFault(serviceStepId),
                                string.Format("Этап услуги [{0}] не найден", serviceStepId));
                        }
                        serviceRendering.ServiceStep = serviceStep;
                    }
                    else
                    {
                        serviceRendering.ServiceStep = null;
                    }

                    serviceRendering.Mode = source.Mode;
                    serviceRendering.Priority = source.Priority;

                    var errors = serviceRendering.Validate();
                    if (errors.Length > 0)
                    {
                        throw new FaultException(errors.First().Message);
                    }

                    session.Save(serviceRendering);

                    var todayQueuePlan = QueueInstance.TodayQueuePlan;
                    using (var locker = todayQueuePlan.WriteLock())
                    {
                        transaction.Commit();

                        todayQueuePlan.Flush(QueuePlanFlushMode.ServiceRenderings);
                        todayQueuePlan.Build(DateTime.Now.TimeOfDay);
                    }

                    return Mapper.Map<ServiceRendering, DTO.ServiceRendering>(serviceRendering);
                }
            });
//.........这里部分代码省略.........
开发者ID:breslavsky,项目名称:queue,代码行数:101,代码来源:ServiceRendering.cs

示例10: EditClient

        public async Task<DTO.Client> EditClient(DTO.Client source)
        {
            return await Task.Run(() =>
            {
                CheckPermission(UserRole.Administrator, AdministratorPermissions.Clients);

                using (var session = SessionProvider.OpenSession())
                using (var transaction = session.BeginTransaction())
                {
                    string surname = source.Surname;
                    string name = source.Name;
                    string patronymic = source.Patronymic;
                    string email = source.Email;
                    string mobile = source.Mobile;
                    string identity = source.Identity;

                    Client client = null;

                    if (!source.Empty())
                    {
                        var clientId = source.Id;
                        client = session.Get<Client>(clientId);
                        if (client == null)
                        {
                            throw new FaultException<ObjectNotFoundFault>(new ObjectNotFoundFault(clientId), string.Format("Клиент [{0}] не найден", clientId));
                        }
                    }
                    else
                    {
                        bool hasEmail = !string.IsNullOrWhiteSpace(email);

                        if (hasEmail)
                        {
                            int count = session.CreateCriteria<Client>()
                                .Add(Expression.Eq("Email", email))
                                .SetProjection(Projections.RowCount())
                                .UniqueResult<int>();

                            if (count > 0)
                            {
                                throw new FaultException("Клиент с таким электронным адресом уже существует");
                            }
                        }

                        bool hasIdentity = !string.IsNullOrWhiteSpace(identity);

                        if (hasIdentity)
                        {
                            int count = session.CreateCriteria<Client>()
                                .Add(Expression.Eq("Identity", identity))
                                .SetProjection(Projections.RowCount())
                                .UniqueResult<int>();

                            if (count > 0)
                            {
                                throw new FaultException("Клиент с данной идентификацией уже существует");
                            }
                        }

                        if (!hasEmail && !hasIdentity)
                        {
                            client = session.CreateCriteria<Client>()
                                .Add(new Conjunction()
                                    .Add(Expression.Eq("Surname", surname))
                                    .Add(Expression.Eq("Name", name))
                                    .Add(Expression.Eq("Patronymic", patronymic)))
                                .SetMaxResults(1)
                                .UniqueResult<Client>();
                        }

                        if (client == null)
                        {
                            client = new Client()
                            {
                                SessionId = Guid.NewGuid()
                            };
                        }
                    }

                    client.Surname = surname;
                    client.Name = name;
                    client.Patronymic = patronymic;
                    client.Email = email;
                    client.Mobile = mobile;
                    client.Identity = identity;

                    var errors = client.Validate();
                    if (errors.Length > 0)
                    {
                        throw new FaultException(errors.First().Message);
                    }

                    string password = source.Password;

                    if (!string.IsNullOrWhiteSpace(password))
                    {
                        try
                        {
                            client.SetPassword(password);
                        }
//.........这里部分代码省略.........
开发者ID:breslavsky,项目名称:queue,代码行数:101,代码来源:Clients.cs

示例11: EditServiceStep

        public async Task<DTO.ServiceStep> EditServiceStep(DTO.ServiceStep source)
        {
            return await Task.Run(() =>
            {
                CheckPermission(UserRole.Administrator, AdministratorPermissions.Services);

                using (var session = SessionProvider.OpenSession())
                using (var transaction = session.BeginTransaction())
                {
                    ServiceStep serviceStep;

                    if (!source.Empty())
                    {
                        var serviceStepId = source.Id;
                        serviceStep = session.Get<ServiceStep>(serviceStepId);
                        if (serviceStep == null)
                        {
                            throw new FaultException<ObjectNotFoundFault>(new ObjectNotFoundFault(serviceStepId),
                                string.Format("Этап услуги [{0}] не найден", serviceStepId));
                        }
                    }
                    else
                    {
                        serviceStep = new ServiceStep();
                    }

                    if (source.Service != null)
                    {
                        var serviceId = source.Service.Id;

                        var service = session.Get<Service>(serviceId);
                        if (service == null)
                        {
                            throw new FaultException<ObjectNotFoundFault>(new ObjectNotFoundFault(serviceId),
                                string.Format("Услуга [{0}] не найдена", serviceId));
                        }
                        serviceStep.Service = service;
                    }
                    else
                    {
                        serviceStep.Service = null;
                    }

                    serviceStep.Name = source.Name;

                    var errors = serviceStep.Validate();
                    if (errors.Length > 0)
                    {
                        throw new FaultException(errors.First().Message);
                    }

                    session.Save(serviceStep);
                    transaction.Commit();

                    return Mapper.Map<ServiceStep, DTO.ServiceStep>(serviceStep);
                }
            });
        }
开发者ID:breslavsky,项目名称:queue,代码行数:58,代码来源:ServiceStep.cs

示例12: EditWorkplace

        public async Task<DTO.Workplace> EditWorkplace(DTO.Workplace source)
        {
            return await Task.Run(() =>
            {
                CheckPermission(UserRole.Administrator, AdministratorPermissions.Workplaces);

                using (var session = SessionProvider.OpenSession())
                using (var transaction = session.BeginTransaction())
                {
                    Workplace workplace;

                    if (!source.Empty())
                    {
                        var workplaceId = source.Id;
                        workplace = session.Get<Workplace>(workplaceId);
                        if (workplace == null)
                        {
                            throw new FaultException<ObjectNotFoundFault>(new ObjectNotFoundFault(workplaceId), string.Format("Рабочее место [{0}] не найдено", workplaceId));
                        }
                    }
                    else
                    {
                        workplace = new Workplace();
                    }

                    workplace.Type = source.Type;
                    workplace.Number = source.Number;
                    workplace.Modificator = source.Modificator;
                    workplace.Comment = source.Comment;
                    workplace.DisplayDeviceId = source.DisplayDeviceId;
                    workplace.QualityPanelDeviceId = source.QualityPanelDeviceId;

                    var errors = workplace.Validate();
                    if (errors.Length > 0)
                    {
                        throw new FaultException(errors.First().Message);
                    }

                    session.Save(workplace);

                    var todayQueuePlan = QueueInstance.TodayQueuePlan;
                    using (var locker = todayQueuePlan.WriteLock())
                    {
                        transaction.Commit();

                        todayQueuePlan.Put(workplace);
                    }

                    return Mapper.Map<Workplace, DTO.Workplace>(workplace);
                }
            });
        }
开发者ID:breslavsky,项目名称:queue,代码行数:52,代码来源:WorkplaceService.cs

示例13: EditClientRequestAdditionalService

        public async Task<DTO.ClientRequestAdditionalService> EditClientRequestAdditionalService(DTO.ClientRequestAdditionalService source)
        {
            return await Task.Run(() =>
            {
                CheckPermission(UserRole.Operator);

                using (var session = SessionProvider.OpenSession())
                using (var transaction = session.BeginTransaction())
                {
                    ClientRequestAdditionalService clientRequestAdditionalService;

                    if (!source.Empty())
                    {
                        var clientRequestAdditionalServiceId = source.Id;
                        clientRequestAdditionalService = session.Get<ClientRequestAdditionalService>(clientRequestAdditionalServiceId);
                        if (clientRequestAdditionalService == null)
                        {
                            throw new FaultException<ObjectNotFoundFault>(new ObjectNotFoundFault(clientRequestAdditionalServiceId),
                                string.Format("Дополнительная услуга запроса клиента [{0}] не найдена", clientRequestAdditionalServiceId));
                        }
                    }
                    else
                    {
                        clientRequestAdditionalService = new ClientRequestAdditionalService();
                    }

                    if (source.ClientRequest != null)
                    {
                        Guid clientRequestId = source.ClientRequest.Id;

                        ClientRequest clientRequest = session.Get<ClientRequest>(clientRequestId);
                        if (clientRequest == null)
                        {
                            throw new FaultException<ObjectNotFoundFault>(new ObjectNotFoundFault(clientRequestId),
                                string.Format("Запрос клиента [{0}] не найден", clientRequestId));
                        }

                        clientRequestAdditionalService.ClientRequest = clientRequest;
                    }
                    else
                    {
                        clientRequestAdditionalService.ClientRequest = null;
                    }

                    if (source.AdditionalService != null)
                    {
                        Guid additionalServiceId = source.AdditionalService.Id;

                        AdditionalService additionalService = session.Get<AdditionalService>(additionalServiceId);
                        if (additionalService == null)
                        {
                            throw new FaultException<ObjectNotFoundFault>(new ObjectNotFoundFault(additionalServiceId),
                                string.Format("Дополнительная услуга [{0}] не найдена", additionalServiceId));
                        }

                        clientRequestAdditionalService.AdditionalService = additionalService;
                    }
                    else
                    {
                        clientRequestAdditionalService.AdditionalService = null;
                    }

                    clientRequestAdditionalService.Operator = currentUser as Operator;
                    clientRequestAdditionalService.Quantity = source.Quantity;

                    var errors = clientRequestAdditionalService.Validate();
                    if (errors.Length > 0)
                    {
                        throw new FaultException(errors.First().Message);
                    }

                    session.Save(clientRequestAdditionalService);
                    transaction.Commit();

                    return Mapper.Map<ClientRequestAdditionalService, DTO.ClientRequestAdditionalService>(clientRequestAdditionalService);
                }
            });
        }
开发者ID:breslavsky,项目名称:queue,代码行数:78,代码来源:ClientRequestAdditionalService.cs

示例14: EditMediaConfigFile

        public async Task<DTO.MediaConfigFile> EditMediaConfigFile(DTO.MediaConfigFile source)
        {
            return await Task.Run(() =>
            {
                CheckPermission(UserRole.Administrator, AdministratorPermissions.Config);

                using (var session = SessionProvider.OpenSession())
                using (var transaction = session.BeginTransaction())
                {
                    MediaConfigFile mediaConfigFile;

                    if (!source.Empty())
                    {
                        var mediaConfigFileId = source.Id;
                        mediaConfigFile = session.Get<MediaConfigFile>(mediaConfigFileId);
                        if (mediaConfigFile == null)
                        {
                            throw new FaultException<ObjectNotFoundFault>(new ObjectNotFoundFault(mediaConfigFileId), string.Format("Медиафайл [{0}] не найден", mediaConfigFileId));
                        }
                    }
                    else
                    {
                        mediaConfigFile = new MediaConfigFile();
                    }

                    mediaConfigFile.Name = source.Name;

                    var errors = mediaConfigFile.Validate();
                    if (errors.Length > 0)
                    {
                        throw new FaultException(errors.First().Message);
                    }

                    session.Save(mediaConfigFile);
                    transaction.Commit();

                    return Mapper.Map<MediaConfigFile, DTO.MediaConfigFile>(mediaConfigFile);
                }
            });
        }
开发者ID:breslavsky,项目名称:queue,代码行数:40,代码来源:Config.cs

示例15: EditOperatorInterruption

        public async Task<DTO.OperatorInterruption> EditOperatorInterruption(DTO.OperatorInterruption source)
        {
            return await Task.Run(() =>
            {
                CheckPermission(UserRole.Administrator, AdministratorPermissions.Users);

                using (var session = SessionProvider.OpenSession())
                using (var transaction = session.BeginTransaction())
                {
                    OperatorInterruption interruption;

                    if (!source.Empty())
                    {
                        var operatorInterruptionId = source.Id;
                        interruption = session.Get<OperatorInterruption>(operatorInterruptionId);
                        if (interruption == null)
                        {
                            throw new FaultException<ObjectNotFoundFault>(new ObjectNotFoundFault(operatorInterruptionId),
                                string.Format("Перерыв оператора [{0}] не найден", operatorInterruptionId));
                        }
                    }
                    else
                    {
                        interruption = new OperatorInterruption();
                    }

                    interruption.Type = source.Type;
                    interruption.TargetDate = source.TargetDate.Date;
                    interruption.DayOfWeek = source.DayOfWeek;
                    interruption.StartTime = source.StartTime;
                    interruption.FinishTime = source.FinishTime;
                    interruption.ServiceRenderingMode = source.ServiceRenderingMode;
                    interruption.WeekFold = source.WeekFold;

                    if (source.Operator != null)
                    {
                        Guid operatorId = source.Operator.Id;

                        Operator queueOperator = session.Get<Operator>(operatorId);
                        if (queueOperator == null)
                        {
                            throw new FaultException<ObjectNotFoundFault>(new ObjectNotFoundFault(operatorId),
                                string.Format("Оператор [{0}] не найден", operatorId));
                        }

                        interruption.Operator = queueOperator;
                    }
                    else
                    {
                        interruption.Operator = null;
                    }

                    var errors = interruption.Validate();
                    if (errors.Length > 0)
                    {
                        throw new FaultException(errors.First().Message);
                    }

                    session.Save(interruption);

                    var todayQueuePlan = QueueInstance.TodayQueuePlan;
                    using (var locker = todayQueuePlan.WriteLock())
                    {
                        transaction.Commit();

                        todayQueuePlan.Flush(QueuePlanFlushMode.OperatorInterruptions);
                        todayQueuePlan.Build(DateTime.Now.TimeOfDay);
                    }

                    return Mapper.Map<OperatorInterruption, DTO.OperatorInterruption>(interruption);
                }
            });
        }
开发者ID:breslavsky,项目名称:queue,代码行数:73,代码来源:OperatorInterruption.cs


注:本文中的DTO.Empty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。