Ejemplo n.º 1
0
 public IActionResult Delete(int id)
 {
     try
     {
         CountryAddressDescription countryAddressDescription = _countryInfoContext.GetWithId(id);
         if (countryAddressDescription == null)
         {
             return(StatusCode(StatusCodes.Status500InternalServerError, new Response
             {
                 Status = "Error",
                 Messages = new Message[] {
                     new Message {
                         Lang_id = 1,
                         MessageLang = "Model state isn't valid!"
                     },
                     new Message {
                         Lang_id = 2,
                         MessageLang = "Состояние модели недействительно!"
                     },
                     new Message {
                         Lang_id = 3,
                         MessageLang = "Model vəziyyəti etibarsızdır!"
                     }
                 }
             }));
         }
         _countryInfoContext.Detele(id);
         return(Ok());
     }
     catch (Exception e)
     {
         return(StatusCode(StatusCodes.Status500InternalServerError, e.Message));
     }
 }
Ejemplo n.º 2
0
 public IActionResult Post([FromForm] CountryAddressDescription countryAddressDescription)
 {
     try
     {
         if (!ModelState.IsValid)
         {
             return(StatusCode(StatusCodes.Status500InternalServerError, new Response
             {
                 Status = "Error",
                 Messages = new Message[] {
                     new Message {
                         Lang_id = 1,
                         MessageLang = "Model state isn't valid!"
                     },
                     new Message {
                         Lang_id = 2,
                         MessageLang = "Состояние модели недействительно!"
                     },
                     new Message {
                         Lang_id = 3,
                         MessageLang = "Model vəziyyəti etibarsızdır!"
                     }
                 }
             }));
         }
         Country db_country = _countryContext.GetWithId(countryAddressDescription.CountryId);
         if (db_country == null)
         {
             return(StatusCode(StatusCodes.Status500InternalServerError, new Response
             {
                 Status = "Error",
                 Messages = new Message[] {
                     new Message {
                         Lang_id = 1,
                         MessageLang = "Model state isn't valid!"
                     },
                     new Message {
                         Lang_id = 2,
                         MessageLang = "Состояние модели недействительно!"
                     },
                     new Message {
                         Lang_id = 3,
                         MessageLang = "Model vəziyyəti etibarsızdır!"
                     }
                 }
             }));
         }
         _countryInfoContext.Add(countryAddressDescription);
         return(Ok());
     }
     catch (Exception e)
     {
         return(StatusCode(StatusCodes.Status500InternalServerError, e.Message));
     }
 }
Ejemplo n.º 3
0
 public void Update(CountryAddressDescription data)
 {
     _context.Update(data);
 }
Ejemplo n.º 4
0
 public void Add(CountryAddressDescription data)
 {
     _context.Add(data);
 }