Ejemplo n.º 1
0
        public IHttpActionResult PutLanguage(int id, LanguageDTO language)
        {
            //language = new LanguageDTO();
            //language.LanguageName = "Hindi";
            //language.UserID = 50;
            //language.LanguageID = id;

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != language.LanguageID)
            {
                return(BadRequest());
            }

            try
            {
                db.Update(language);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!LanguageExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Ejemplo n.º 2
0
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        int index = 0;

        foreach (GridViewRow gvr in GridView1.Rows)
        {
            if (index > 0)
            {
                TextBox type_vi = ((TextBox)gvr.FindControl("Content_vi"));
                type_vi.Enabled = false;
                TextBox type_en = ((TextBox)gvr.FindControl("Content_en"));
                type_en.Enabled = false;
                TextBox type_other = ((TextBox)gvr.FindControl("Content_other"));
                type_other.Enabled = false;

                // Update to SQL
                t_LanguageTranslate entity_vi = new t_LanguageTranslate
                {
                    Contents = type_vi.Text,
                };
                string Id_vi        = (gvr.FindControl("Id_vi") as HiddenField).Value;
                bool   updateStatus = languageBL.Update(entity_vi, int.Parse(Id_vi));

                t_LanguageTranslate entity_en = new t_LanguageTranslate
                {
                    Contents = type_en.Text,
                };
                string Id_en = (gvr.FindControl("Id_en") as HiddenField).Value;
                updateStatus = languageBL.Update(entity_en, int.Parse(Id_en));

                t_LanguageTranslate entity_other = new t_LanguageTranslate
                {
                    Contents = type_other.Text,
                };
                string Id_other = (gvr.FindControl("Id_other") as HiddenField).Value;
                updateStatus = languageBL.Update(entity_other, int.Parse(Id_other));
            }
            index++;
        }
    }
 protected void btnSave_Click(object sender, EventArgs e)
 {
     if (Page.IsValid)
     {
         ntf.VisibleOnPageLoad = true;
         t_LanguageTranslate entity = new t_LanguageTranslate
         {
             Contents = txtContent.Text,
             Noted    = txtNoted.Text
         };
         bool   updateStatus = languageBL.Update(entity, contentId);
         string message      = (updateStatus) ? "Cập nhật thành công" : "Cập nhật không thành công";
         ntf.Text = message;
     }
 }