Exemplo n.º 1
0
        public static uint GetConferenceId()
        {
            if (_conferenceId != 0)
            {
                return(_conferenceId);
            }
            var conference = GetConference(ProjectConsts.DefaultConferenceName);

            //current approach used for hardcoded one Conference without selection
            if (conference == null)
            {
                throw new XmlException(AppResources.GetResource("ConfigNoConferenciesError"));
            }
            var value = conference.Attribute("ID");

            if (value == null)
            {
                throw new XmlException(AppResources.GetResource("ConfigConferenceIDError"));
            }
            var result = uint.Parse(value.Value);

            if (result <= 0)
            {
                throw new ArgumentException(AppResources.GetResource("ConfigCompIDUnexpectedError"));
            }

            _conferenceId = result;
            return(_conferenceId);
        }
        public async Task <ResponseModel <UserModel> > CheckUser(string socialId)
        {
            var result = await UniversalMethod <object, ResponseModel <UserModel> >(null, ProjectConsts.CheckUserMethodName,
                                                                                    AppResources.GetResource("Error"), new object[] { socialId });

            return(result);
        }
Exemplo n.º 3
0
        public static string GetMainServiceUrl()
        {
            if (!string.IsNullOrEmpty(_mainServiceUrl))
            {
                return(_mainServiceUrl);
            }
            var mainService = GetService(ProjectConsts.MainServiceName);

            if (mainService == null)
            {
                throw new XmlException(AppResources.GetResource("ConfigMainServiceMissingError"));
            }
            var url = mainService.Attribute("Url");

            if (url == null)
            {
                throw new XmlException(AppResources.GetResource("ConfigMainServiceUrlSectionMissingError"));
            }
            var urlValue = url.Value;

            if (string.IsNullOrEmpty(urlValue))
            {
                throw new ArgumentException(AppResources.GetResource("ConfigMainServiceUrlBrockenError"));
            }

            _mainServiceUrl = urlValue;
            return(_mainServiceUrl);
        }
        public async Task <ResponseModel <UserModel> > SetUser([NotNull] UserModel user, int id)
        {
            var result =
                await UniversalMethod <UserModel, ResponseModel <UserModel> >(user, ProjectConsts.SetUserMethodName,
                                                                              AppResources.GetResource("Error"), new object[] { id });

            OnUserChanged(new UserUpdatedEventArgs {
                User = result.FirstResponce
            });

            return(result);
        }
Exemplo n.º 5
0
        private static XElement GetConfigEntity(string sectionType, string name)
        {
            if (Settings.Root == null)
            {
                throw new XmlException(AppResources.GetResource("ConfigRootElError"));
            }
            var el = Settings.Root;

            //if (el == null) throw new XmlException(AppResources.ConfigMainElError);
            return(el.DescendantsAndSelf().Where(x => x.Name == sectionType)
                   .FirstOrDefault(element =>
                                   (element.Attribute("Name") ?? new XAttribute("Name", string.Empty)).Value == name));
        }
Exemplo n.º 6
0
        public static List <ServiceMethodModel> GetMainServiceMethods()
        {
            if (_mainServiceMethods != null)
            {
                return(_mainServiceMethods);
            }

            var methods = GetServiceMethods(ProjectConsts.MainServiceName);

            if (!methods.Any())
            {
                throw new XmlException(AppResources.GetResource("ConfigMainServiceMethodMissingError"));
            }
            _mainServiceMethods = methods;

            return(_mainServiceMethods);
        }
Exemplo n.º 7
0
        public static string GetLocalisedDescription(this Enum value)
        {
            FieldInfo fi = value.GetType().GetTypeInfo().GetDeclaredField(value.ToString());

            DisplayAttribute[] attributes =
                (DisplayAttribute[])fi.GetCustomAttributes(
                    typeof(DisplayAttribute),
                    false);

            if (attributes != null &&
                attributes.Length > 0)
            {
                return(AppResources.GetResource(attributes[0].Name));
            }

            return(value.ToString());
        }
        public async Task <ResponseModel <StaffModel> > GetStaff(int staffId)
        {
            var cachedStuff = _cache.GetStaff(staffId);

            if (cachedStuff != null)
            {
                return new ResponseModel <StaffModel> {
                           HasErrors = false, FirstResponce = cachedStuff
                }
            }
            ;

            var result =
                await UniversalMethod <object, ResponseModel <StaffModel> >(null, ProjectConsts.GetEventMethodName,
                                                                            AppResources.GetResource("Error"), new object[] { staffId });

            _cache.StaffList.Add(result.FirstResponce);

            return(result);
        }
        public async Task <ResponseModel <EventModel> > GetEvent(int eventId)
        {
            var cachedEvent = _cache.GetEvent(eventId);

            if (cachedEvent != null)
            {
                return new ResponseModel <EventModel> {
                           HasErrors = false, FirstResponce = cachedEvent
                }
            }
            ;

            var result =
                await UniversalMethod <object, ResponseModel <EventModel> >(null, ProjectConsts.GetEventMethodName,
                                                                            AppResources.GetResource("Error"), new object[] { eventId });

            _cache.EventsList.Add(result.FirstResponce);

            return(result);
        }
        public async Task <ResponseModel <MessageModel> > SendMessage(string token, [NotNull] MessageModel msg)
        {
            var result = await UniversalMethod <MessageModel, ResponseModel <MessageModel> >(msg, ProjectConsts.SendMessageMethodName,
                                                                                             AppResources.GetResource("Error"), new object[] { token });

            return(result);
        }
        public async Task <ResponseModel <MessageModel> > GetMessages(string token)
        {
            var result = await UniversalMethod <object, ResponseModel <MessageModel> >(null, ProjectConsts.GetMessagesMethodName,
                                                                                       AppResources.GetResource("Error"), new object[] { token });

            return(result);
        }
 public async Task <ResponseModel <QuestionnaireModel> > AddReview(int userId, [NotNull] QuestionnaireModel review)
 {
     return(await UniversalMethod <QuestionnaireModel, ResponseModel <QuestionnaireModel> >(review, ProjectConsts.AddReviewMethodName,
                                                                                            AppResources.GetResource("Error"), new object[] { userId }));
 }
 public async Task <ResponseModel <UserModel> > GetUser(int userId)
 {
     return(await UniversalMethod <object, ResponseModel <UserModel> >(null, ProjectConsts.GetUserMethodName,
                                                                       AppResources.GetResource("Error"), new object[] { userId }));
 }
        public async Task <ResponseModel <ConferenceModel> > GetConference(int conferenceId)
        {
            var result = await UniversalMethod <object, ResponseModel <ConferenceModel> >(null, ProjectConsts.GetConferenceMethodName,
                                                                                          AppResources.GetResource("Error"), new object[] { conferenceId });

            _cache.Conference = result.FirstResponce;

            return(result);
        }
Exemplo n.º 15
0
 private static void CreateStackBlock([NotNull] StringBuilder result, [NotNull] List <ErrorModel> errors, [NotNull] string headlineResource)
 {
     result.Append(AppResources.GetResource(headlineResource) + Environment.NewLine);
     result.Append(string.Join(ErrorSeparator, errors));
     result.Append(Environment.NewLine + Environment.NewLine);
 }
        public async Task <ResponseModel <UserModel> > AddUserToConf(string token, int conferenceId, UserType type)
        {
            var result = await UniversalMethod <Dictionary <string, string>, ResponseModel <UserModel> >(new Dictionary <string, string>(1) { { "type", type.GetLocalisedDescription() } }, ProjectConsts.AddUserToConfMethodName, //TODO: move to enums
                                                                                                         AppResources.GetResource("Error"), new object[] { token, conferenceId },
                                                                                                         true, "application/x-www-form-urlencoded");

            return(result);
        }
        public async Task <ResponseModel <RatingModel> > SetStaffRate([NotNull] RatingModel rating, int eventId, int staffId)
        {
            var result = await UniversalMethod <RatingModel, ResponseModel <RatingModel> >(rating, ProjectConsts.SetStaffRateMethodName,
                                                                                           AppResources.GetResource("Error"), new object[] { eventId, staffId });

            OnStaffVoted(new StaffVotedEventArgs {
                StaffId = staffId, Vote = rating.Rating
            });

            return(result);
        }