Пример #1
0
        public object DeletePaymentPeriod(int paymentPeriodId, string token)
        {
            bool   wasSuccess   = false;
            string errorMessage = string.Empty;
            var    resultList   = new List <object>();
            DictionaryController dictionaryController = new DictionaryController();

            try
            {
                int userId;
                if (Security.UserTokens.Any(i => i.Value == token))
                {
                    userId = Security.UserTokens.FirstOrDefault(i => i.Value == token).Key;
                }
                else
                {
                    throw new Exception("Identyfikacja użytkownika nie powiodła się");
                }
                wasSuccess = true;
                DeletePaymentPeriodDetailed(paymentPeriodId, userId);
                resultList = dictionaryController.GetPaymentPeriodDictionary().ToList();
            }
            catch (Exception ex)
            {
                errorMessage = ex.Message;
            }

            var finalResult = new
            {
                success = wasSuccess,
                message = errorMessage,
                list    = dictionaryController.GetPaymentPeriodDictionary().ToList()
            };

            return(finalResult);
        }
Пример #2
0
        public object EditCity(string cityName, int provinceId, int cityId, double longitude, double latitude, string token)
        {
            bool   wasSuccess   = false;
            string errorMessage = string.Empty;
            var    resultList   = new List <object>();
            DictionaryController dictionaryController = new DictionaryController();

            try
            {
                int userId;
                if (Security.UserTokens.Any(i => i.Value == token))
                {
                    userId = Security.UserTokens.FirstOrDefault(i => i.Value == token).Key;
                }
                else
                {
                    throw new Exception("Identyfikacja użytkownika nie powiodła się");
                }
                wasSuccess = true;
                EditCityDetailed(cityName, provinceId, cityId, longitude, latitude, userId);
                resultList = dictionaryController.GetCityDictionary().ToList();
            }
            catch (Exception ex)
            {
                errorMessage = ex.Message;
            }

            var finalResult = new
            {
                success = wasSuccess,
                message = errorMessage,
                list    = dictionaryController.GetCityDictionary().ToList()
            };

            return(finalResult);
        }