Exemplo n.º 1
0
        public IActionResult Put(int id, [FromForm] ContactNotice contactNotice)
        {
            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!"
                            }
                        }
                    }));
                }
                ContactNotice db_contactNotice = _noticeContext.GetWithId(id);
                if (db_contactNotice == 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!"
                            }
                        }
                    }));
                }

                db_contactNotice.DescAz  = contactNotice.DescAz;
                db_contactNotice.DescRus = contactNotice.DescRus;
                db_contactNotice.DescEng = contactNotice.DescEng;
                _noticeContext.Update(db_contactNotice);
                return(Ok());
            }
            catch (Exception e)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, e.Message));
            }
        }
Exemplo n.º 2
0
 public void Update(ContactNotice data)
 {
     _context.Update(data);
 }
Exemplo n.º 3
0
 public void Add(ContactNotice data)
 {
     _context.Add(data);
 }