public IActionResult ChkCurrXDtT([FromBody] SM.Currency_Exchange x)
        {
            try
            {
                if (x is null)
                {
                    throw new ArgumentNullException("Currency Exchange Object Empty (" + where + ") (CT)");
                }
                if (x.CurrFrom.Length == 3)
                {
                    throw new DataException("Currency From must be 3 digits (" + where + ") (CT)");
                }
                if (x.CurrTo.Length == 3)
                {
                    throw new DataException("Currency To must be 3 digits (" + where + ") (CT)");
                }

                int RcdCntTo = S.ServiceLocator.Instance.Currency_ExchangeService.Check_DateT(new SM.Currency_Exchange(0, x.CurrFrom, x.CurrTo, x.DateFrom, x.DateTo, x.Rate));
                return(ApiControllerHelper.SendOk(this, new ApiResult <int>(HttpStatusCode.OK, null, RcdCntTo), HttpStatusCode.OK));
            }
            catch (Exception ex)
            {
                return(ApiControllerHelper.SendError(this, ex));
            }
        }
        public IActionResult Add([FromBody] Currency_Exchange x)
        {
            try
            {
                if (x is null)
                {
                    throw new ArgumentNullException("Currency Exchange Object Empty (" + where + ") (ADD)");
                }
                if (x.CurrFrom.Length != 3)
                {
                    throw new DataException("Currency From must be 3 digits (" + where + ") (ADD)");
                }
                if (x.CurrTo.Length != 3)
                {
                    throw new DataException("Currency To must be 3 digits (" + where + ") (ADD)");
                }
                if (x.DateFrom > x.DateTo)
                {
                    throw new DataException("Date From Bigger than Date To (" + where + ") (ADD)");
                }

                S.ServiceLocator.Instance.Currency_ExchangeService.Add(new SM.Currency_Exchange(0, x.CurrFrom, x.CurrTo, x.DateFrom, x.DateTo, x.Rate));
                return(ApiControllerHelper.SendOk(this));
            }
            catch (Exception ex)
            {
                return(ApiControllerHelper.SendError(this, ex));
            }
        }
        public IActionResult Upd(int id, [FromBody] Currency_Exchange x)
        {
            try
            {
                if (id < 1)
                {
                    throw new IndexOutOfRangeException("ID must be greater than 0 (" + where + ") (UPD)");
                }
                if (x is null)
                {
                    throw new ArgumentNullException("Currency Exchange Object Empty (" + where + ") (UPD)");
                }
                if (x.CurrFrom.Length != 3)
                {
                    throw new DataException("Currency From must be 3 digits (" + where + ") (UPD)");
                }
                if (x.CurrTo.Length != 3)
                {
                    throw new DataException("Currency To must be 3 digits (" + where + ") (UPD)");
                }
                if (x.DateFrom > x.DateTo)
                {
                    throw new DataException("Date From Bigger than Date To (" + where + ") (UPD)");
                }

                bool UpdOk = S.ServiceLocator.Instance.Currency_ExchangeService.Upd(new SM.Currency_Exchange(id, x.CurrFrom, x.CurrTo, x.DateFrom, x.DateTo, x.Rate));
                return(ApiControllerHelper.SendOk(this, new ApiResult <bool>(HttpStatusCode.OK, null, UpdOk), HttpStatusCode.OK));
            }
            catch (Exception ex)
            {
                return(ApiControllerHelper.SendError(this, ex));
            }
        }
示例#4
0
        public IActionResult Add([FromBody] UserAddForm u)
        {
            try
            {
                if (u is null)
                {
                    throw new ArgumentNullException("User Object Empty (ADD)");
                }

                string testpasswd = _cryptoService.Decrypter(Convert.FromBase64String(u.Passwd));
                // User uo = new User() {Email = u.Email, NatRegNbr = u.NatRegNbr, FirstName = u.FirstName, LastName = u.LastName, Passwd = (Base64.Base64Decode(u.Passwd)};
                User uo = new User()
                {
                    Email = u.Email, NatRegNbr = u.NatRegNbr, FirstName = u.FirstName, LastName = u.LastName, Passwd = _cryptoService.Decrypter(Convert.FromBase64String(u.Passwd))
                };



                uo = _clientService.Add(uo);
                return(ApiControllerHelper.SendOk(this, new ApiResult <User>(HttpStatusCode.OK, null, uo), true));
            }
            catch (Exception ex)
            {
                return(ApiControllerHelper.SendError(this, ex));
            }
        }
 public IActionResult Upd([FromBody] SM.Currency cur)
 {
     try
     {
         if (cur is null)
         {
             throw new ArgumentNullException("Currency Object Empty (" + where + ") (UPD)");
         }
         if (cur.Curr is null)
         {
             throw new ArgumentNullException("Currency Curr Empty (" + where + ") (UPD)");
         }
         if (cur.Curr.Length != 3)
         {
             throw new IndexOutOfRangeException("Currency must be 3 digits (" + where + ") (UPD)");
         }
         SM.Currency curo  = new SM.Currency(cur.Curr, cur.Desc);
         bool        UpdOk = S.ServiceLocator.Instance.CurrencyService.Upd(curo);
         return(ApiControllerHelper.SendOk(this, new ApiResult <bool>(HttpStatusCode.OK, null, UpdOk), HttpStatusCode.OK));
     }
     catch (Exception ex)
     {
         return(ApiControllerHelper.SendError(this, ex));
     }
 }
        public IActionResult Upd(int id, [FromBody] MusicType mt)
        {
            try
            {
                if (id < 1)
                {
                    throw new IndexOutOfRangeException("ID must be greater than 0 (" + where + ") (UPD)");
                }
                if (mt is null)
                {
                    throw new ArgumentNullException("Music Type Object Empty (" + where + ") (UPD)");
                }
                if (mt.Name.Length == 0)
                {
                    throw new DataException("Music Type NAme can't be BLANK (" + where + ") (UPD)");
                }

                SM.MusicType mto   = new SM.MusicType(id, mt.Name);
                bool         UpdOk = S.ServiceLocator.Instance.MusicTypeService.Upd(mto);
                return(ApiControllerHelper.SendOk(this, new ApiResult <bool>(HttpStatusCode.OK, null, UpdOk), HttpStatusCode.OK));
            }
            catch (Exception ex)
            {
                return(ApiControllerHelper.SendError(this, ex));
            }
        }
        public IActionResult Upd(int id, [FromBody] Shop_upd supd)
        {
            try
            {
                if (id < 1)
                {
                    throw new IndexOutOfRangeException("ID must be greater than 0 (" + where + ") (UPD)");
                }
                if (supd is null)
                {
                    throw new ArgumentNullException("Shop Upd Object Empty (" + where + ") (UPD)");
                }
                if (supd.Name.Length == 0)
                {
                    throw new DataException("Shop Name can't be BLANK (" + where + ") (UPD)");
                }

                //if (!ModelState.IsValid) throw new ValidationException("Model is not meeting requirement");
                SM.Shop s     = new SM.Shop(id, supd.Name, supd.Address1, supd.Address2, supd.ZIP, supd.City, supd.Country, supd.Phone, supd.Email, supd.WebSite, supd.LocalisationURL, supd.Closed);
                bool    UpdOk = S.ServiceLocator.Instance.shopService.Upd(s);
                return(ApiControllerHelper.SendOk(this, new ApiResult <bool>(HttpStatusCode.OK, null, UpdOk), HttpStatusCode.OK));
            }
            catch (Exception ex)
            {
                return(ApiControllerHelper.SendError(this, ex));
            }
        }
        public IActionResult RenewToken()
        {
            try
            {
                // check if claimtype Exist in the Token
                bool hasUsernamer = HttpContext.User.HasClaim(c => c.Type == ClaimTypes.NameIdentifier);
                if (!hasUsernamer)
                {
                    throw new SecurityTokenException("Issue with Token (no ClaimTypes.NameIdentifier (" + where + ") (RENEW)");
                }

                // get back value ID from the Token & tryto Parse into Int
                string valueUsername = HttpContext.User.Claims.SingleOrDefault(c => c.Type == ClaimTypes.NameIdentifier).Value;
                int    id2w;
                bool   ParseSuccess = int.TryParse(valueUsername, out id2w);

                if (!ParseSuccess)
                {
                    throw new SecurityTokenException("Issue with Token (TryParse)" + valueUsername + " (" + where + ") (RENEW)");
                }

                // Get back user data
                SM.User u = S.ServiceLocator.Instance.usersService.Get(id2w);
                if (u is null)
                {
                    throw new AuthenticationException("Record not found for Renew Token (" + id2w.ToString() + ") (" + where + ") (RENEW)");
                }

                return(ApiControllerHelper.SendOk(this, new ApiResult <JWT_Bearer>(HttpStatusCode.OK, null, GenToken(u)), true));
            }
            catch (Exception ex)
            {
                return(ApiControllerHelper.SendError(this, ex));
            }
        }
 public IActionResult Add([FromBody] Currency cur)
 {
     try
     {
         if (cur is null)
         {
             throw new ArgumentNullException("Currency Object Empty (" + where + ") (ADD)");
         }
         if (cur.Curr is null)
         {
             throw new ArgumentNullException("Currency Curr Empty (" + where + ") (ADD)");
         }
         if (cur.Curr.Length != 3)
         {
             throw new IndexOutOfRangeException("Currency must be 3 digits (" + where + ") (ADD)");
         }
         SM.Currency curo = new SM.Currency(cur.Curr, cur.Desc);
         S.ServiceLocator.Instance.CurrencyService.Add(curo);
         return(ApiControllerHelper.SendOk(this));
     }
     catch (Exception ex)
     {
         return(ApiControllerHelper.SendError(this, ex));
     }
 }
示例#10
0
        public IActionResult ChangePasswd([FromBody] ChangePasswd UCP)
        {
            try
            {
                if (UCP.Email.Length == 0)
                {
                    throw new ValidationException("Email empty (" + where + ") (CHG)");
                }
                if (UCP.OldPasswd.Length == 0)
                {
                    throw new ValidationException("Old Password empty (" + where + ") (CHG)");
                }
                if (UCP.Passwd.Length == 0)
                {
                    throw new ValidationException("Password empty (" + where + ") (CHG)");
                }

                bool EmailOK = S.ServiceLocator.Instance.usersService.EmailIsUsed(UCP.Email);
                if (!EmailOK)
                {
                    throw new ValidationException("Email Not Found :" + UCP.Email);
                }

                return(ApiControllerHelper.SendOk(this, new ApiResult <bool>(HttpStatusCode.OK, null, S.ServiceLocator.Instance.usersService.ChangePasswd(UCP.Email, Base64.Base64Decode(UCP.OldPasswd), Base64.Base64Decode(UCP.Passwd))), true));
            }
            catch (Exception ex)
            {
                return(ApiControllerHelper.SendError(this, ex));
            }
        }
示例#11
0
        public IActionResult ResetPasswd([FromBody] ResetPassword URP)
        {
            try
            {
                if (URP.Email.Length == 0)
                {
                    throw new ValidationException("Email empty (" + where + ") (RESET)");
                }
                if (URP.Passwd.Length == 0)
                {
                    throw new ValidationException("password empty (" + where + ") (RESET)");
                }
                if (URP.SecretAnswer.Length == 0)
                {
                    throw new ValidationException("Secret Answer empty (" + where + ") (RESET");
                }

                bool EmailOK = S.ServiceLocator.Instance.usersService.EmailIsUsed(URP.Email);
                if (!EmailOK)
                {
                    throw new ValidationException("Email Not Found :" + URP.Email);
                }

                return(ApiControllerHelper.SendOk(this, new ApiResult <bool>(HttpStatusCode.OK, null, S.ServiceLocator.Instance.usersService.ResetPasswd(URP.Email, Base64.Base64Decode(URP.SecretAnswer), Base64.Base64Decode(URP.Passwd))), true));
            }
            catch (Exception ex)
            {
                return(ApiControllerHelper.SendError(this, ex));
            }
        }
        public IActionResult Add([FromBody] MusicAPI mus)
        {
            try
            {
                if (mus is null)
                {
                    throw new ArgumentNullException("Music Object Empty (" + where + ") (ADD)");
                }
                if (mus.Band.Length == 0)
                {
                    throw new DataException("Band Name can't be BLANK (" + where + ") (ADD)");
                }
                if (mus.Title.Length == 0)
                {
                    throw new DataException("Title can't be BLANK (" + where + ") (ADD)");
                }

                SM.Music musa = new SM.Music(0
                                             , mus.Band, mus.Title, mus.YEAR, mus.TRACKS, mus.NbCDs, mus.NbDvds, mus.NbLps, mus.MTypeId, mus.FormatId, mus.SerialNbr, mus.Ctry,
                                             "", "",
                                             mus.Price, mus.Curr, mus.ShopId, "", mus.Date, 1, mus.Signed, mus.SignedBy, mus.EAN, mus.EAN_EXT, mus.Comment1, mus.Comment2, mus.Onwed
                                             );

                musa = S.ServiceLocator.Instance.MusicService.Add(musa);

                return(ApiControllerHelper.SendOk(this, new ApiResult <SM.Music>(HttpStatusCode.OK, null, musa), true));
            }
            catch (Exception ex) { return(ApiControllerHelper.SendError(this, ex)); }
        }
 public IActionResult ListBands()
 {
     try
     {
         return(ApiControllerHelper.SendOk(this, new ApiResult <string>(HttpStatusCode.OK, null, S.ServiceLocator.Instance.MusicService.ListBand()), true));
     }
     catch (Exception ex) { return(ApiControllerHelper.SendError(this, ex)); }
 }
 public IActionResult Del(int id)
 {
     try
     {
         return(ApiControllerHelper.SendOk(this, new ApiResult <bool>(HttpStatusCode.OK, null, S.ServiceLocator.Instance.MusicService.Del(id)), HttpStatusCode.OK));
     }
     catch (Exception ex) { return(ApiControllerHelper.SendError(this, ex)); }
 }
 public IActionResult GetAll()
 {
     try
     {
         IEnumerable <SM.Music> mus = S.ServiceLocator.Instance.MusicService.Get();
         return(ApiControllerHelper.SendOk(this, new ApiResult <SM.Music>(HttpStatusCode.OK, null, mus), true));
     }
     catch (Exception ex) { return(ApiControllerHelper.SendError(this, ex)); }
 }
示例#16
0
        public IActionResult SearchOEAN([FromQuery] int page, [FromQuery] string search)
        {
            try
            {
                if (page < 1)
                {
                    throw new DataException("Page Number must be at least 1 (" + where + ") (ST)");
                }
                if (search.Length == 0)
                {
                    throw new DataException("Search String can't be BLANK (" + where + ") (ST)");
                }

                int       jump, records, maxpages = 1;
                Code_Mstr cdm = S.ServiceLocator.Instance.CodeMstrService.Get(new Code_Mstr("CONFIGURATION", "JUMP_OBJECT", ""));
                if (cdm is null)
                {
                    jump = 50;
                }
                else if (!int.TryParse(cdm.Code_Desc, out jump))
                {
                    jump = 50;
                }

                records = S.ServiceLocator.Instance.GeneralTypeService.SearchEANcnt(search);
                IEnumerable <GenObjectSearch> objs = null;
                if (records > 0)
                {
                    if (records > jump)
                    {
                        maxpages = records / jump;
                        if (records % jump > 0)
                        {
                            maxpages += 1;
                        }
                    }

                    if (page <= maxpages)
                    {
                        objs = S.ServiceLocator.Instance.GeneralTypeService.SearchEAN(page, jump, search);
                    }
                    if (objs != null && objs.OfType <GenObjectSearch>().Count() == 0)
                    {
                        objs = null;
                    }
                }

                ObjectDTO odto = new ObjectDTO(records, maxpages, page, jump, objs);

                return(ApiControllerHelper.SendOk(this, new ApiResult <ObjectDTO>(HttpStatusCode.OK, null, odto), true));
            }
            catch (Exception ex)
            {
                return(ApiControllerHelper.SendError(this, ex));
            }
        }
示例#17
0
 public IActionResult GetYP()
 {
     try
     {
         IEnumerable <SM.GenYearPurch> yp = S.ServiceLocator.Instance.GeneralTypeService.GetYP();
         return(ApiControllerHelper.SendOk(this, new ApiResult <SM.GenYearPurch>(HttpStatusCode.OK, null, yp), true));
     }
     catch (Exception ex)
     {
         return(ApiControllerHelper.SendError(this, ex));
     }
 }
示例#18
0
 public IActionResult VATIsUsed([FromRoute] int id, [FromBody] VatCheckForm vat)
 {
     try
     {
         bool NatRegNbrOk = _clientService.VATIsUsed(vat.VAT, id);
         return(ApiControllerHelper.SendOk(this, new ApiResult <bool>(HttpStatusCode.OK, null, NatRegNbrOk), HttpStatusCode.OK));
     }
     catch (Exception ex)
     {
         return(ApiControllerHelper.SendError(this, ex));
     }
 }
示例#19
0
 public IActionResult NatRegNbrIsUsed([FromRoute] int userId, [FromBody] NatRegNbrForm em)
 {
     try
     {
         bool NatRegNbrOk = _clientService.NatRegNbrIsUsed(em.NatRegNbr, userId);
         return(ApiControllerHelper.SendOk(this, new ApiResult <bool>(HttpStatusCode.OK, null, NatRegNbrOk), HttpStatusCode.OK));
     }
     catch (Exception ex)
     {
         return(ApiControllerHelper.SendError(this, ex));
     }
 }
示例#20
0
 public IActionResult EmailIsUsed([FromRoute] int userId, [FromBody] EmailForm em)
 {
     try
     {
         bool EmailOK = _clientService.EmailIsUsed(em.Email, userId);
         return(ApiControllerHelper.SendOk(this, new ApiResult <bool>(HttpStatusCode.OK, null, EmailOK), HttpStatusCode.OK));
     }
     catch (Exception ex)
     {
         return(ApiControllerHelper.SendError(this, ex));
     }
 }
示例#21
0
 public IActionResult Del([FromRoute] int id)
 {
     try
     {
         bool DelOk = _clientService.Del(id);
         return(ApiControllerHelper.SendOk(this, new ApiResult <bool>(HttpStatusCode.OK, null, DelOk), HttpStatusCode.OK));
     }
     catch (Exception ex)
     {
         return(ApiControllerHelper.SendError(this, ex));
     }
 }
示例#22
0
 public IActionResult EmailIsUsed([FromBody] Email_API em)
 {
     try
     {
         bool EmailOK = S.ServiceLocator.Instance.usersService.EmailIsUsed(em.Email);
         return(ApiControllerHelper.SendOk(this, new ApiResult <bool>(HttpStatusCode.OK, null, EmailOK), HttpStatusCode.OK));
     }
     catch (Exception ex)
     {
         return(ApiControllerHelper.SendError(this, ex));
     }
 }
 public IActionResult GetBand(string band)
 {
     try
     {
         if (band.Length == 0)
         {
             throw new DataException("Band Name can't be BLANK (" + where + ") (GETBAND)");
         }
         return(ApiControllerHelper.SendOk(this, new ApiResult <SM.Music>(HttpStatusCode.OK, null, S.ServiceLocator.Instance.MusicService.FindBand(band)), true));
     }
     catch (Exception ex) { return(ApiControllerHelper.SendError(this, ex)); }
 }
示例#24
0
 public IActionResult Get([FromRoute] int userId, [FromRoute] int id)
 {
     try
     {
         TimeLine tl = _clientService.Get(userId, id);
         return(ApiControllerHelper.SendOk(this, new ApiResult <TimeLine>(HttpStatusCode.OK, null, tl), true));
     }
     catch (Exception ex)
     {
         return(ApiControllerHelper.SendError(this, ex));
     }
 }
 public IActionResult GetEan(string ean)
 {
     try
     {
         if (ean.Length == 0)
         {
             throw new DataException("EAN can't be BLANK (" + where + ") (GETEAN)");
         }
         return(ApiControllerHelper.SendOk(this, new ApiResult <SM.Music>(HttpStatusCode.OK, null, S.ServiceLocator.Instance.MusicService.FindEan(ean)), true));
     }
     catch (Exception ex) { return(ApiControllerHelper.SendError(this, ex)); }
 }
示例#26
0
 public IActionResult Used([FromRoute] string iso)
 {
     try
     {
         int CtryCnt = _clientService.IsUsed(iso);
         return(ApiControllerHelper.SendOk(this, new ApiResult <int>(HttpStatusCode.OK, null, CtryCnt), HttpStatusCode.OK));
     }
     catch (Exception ex)
     {
         return(ApiControllerHelper.SendError(this, ex));
     }
 }
示例#27
0
 public IActionResult IsUsed([FromRoute] int id)
 {
     try
     {
         int NbrRecUsed = _clientService.IsUsed(id);
         return(ApiControllerHelper.SendOk(this, new ApiResult <int>(HttpStatusCode.OK, null, NbrRecUsed), HttpStatusCode.OK));
     }
     catch (Exception ex)
     {
         return(ApiControllerHelper.SendError(this, ex));
     }
 }
示例#28
0
 //[Authorize(Roles = "0,1")]
 public IActionResult Get()
 {
     try
     {
         IEnumerable <Country> ctry = _clientService.Get();
         return(ApiControllerHelper.SendOk(this, new ApiResult <Country>(HttpStatusCode.OK, null, ctry), true));
     }
     catch (Exception ex)
     {
         return(ApiControllerHelper.SendError(this, ex));
     }
 }
示例#29
0
 public IActionResult Get([FromRoute] int id)
 {
     try
     {
         Restaurant resto = _clientService.Get(id);
         return(ApiControllerHelper.SendOk(this, new ApiResult <Restaurant>(HttpStatusCode.OK, null, resto), true));
     }
     catch (Exception ex)
     {
         return(ApiControllerHelper.SendError(this, ex));
     }
 }
示例#30
0
 public IActionResult Get([FromRoute] String iso)
 {
     try
     {
         Country ctry = _clientService.Get(iso);
         return(ApiControllerHelper.SendOk(this, new ApiResult <Country>(HttpStatusCode.OK, null, ctry), true));
     }
     catch (Exception ex)
     {
         return(ApiControllerHelper.SendError(this, ex));
     }
 }