Exemplo n.º 1
0
        public IHttpActionResult PutBaseWord(int id, BaseWord baseWord)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != baseWord.Id)
            {
                return(BadRequest());
            }

            db.Entry(baseWord).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!BaseWordExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 2
0
        public ActionResult DeleteConfirmed(int id)
        {
            BaseWord baseWord = db.BaseWords.Find(id);

            db.BaseWords.Remove(baseWord);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 3
0
 public ActionResult Edit([Bind(Include = "Id,Word")] BaseWord baseWord)
 {
     if (ModelState.IsValid)
     {
         db.Entry(baseWord).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(baseWord));
 }
Exemplo n.º 4
0
        public ActionResult Create([Bind(Include = "Id,Word")] BaseWord baseWord)
        {
            if (ModelState.IsValid)
            {
                db.BaseWords.Add(baseWord);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(baseWord));
        }
Exemplo n.º 5
0
        public IHttpActionResult GetBaseWord(int id)
        {
            BaseWord baseWord = db.BaseWords.Find(id);

            if (baseWord == null)
            {
                return(NotFound());
            }

            return(Ok(baseWord));
        }
Exemplo n.º 6
0
        public IHttpActionResult PostBaseWord(BaseWord baseWord)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.BaseWords.Add(baseWord);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = baseWord.Id }, baseWord));
        }
Exemplo n.º 7
0
        public ExportToWord(string docTemplate)
        {
            _docTemplate = docTemplate;
            FileInfo fileInfo = new FileInfo(_docTemplate);
            string   ext      = fileInfo.Extension.ToUpper();

            if (string.IsNullOrWhiteSpace(_docTemplate) || !fileInfo.Exists || (!ext.Equals(".DOC") && !ext.Equals(".DOCX")))
            {
                throw new ArgumentException("File word template không đúng.");
            }

            _baseWord = new BaseWord();
        }
Exemplo n.º 8
0
        // GET: BaseWords/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            BaseWord baseWord = db.BaseWords.Find(id);

            if (baseWord == null)
            {
                return(HttpNotFound());
            }
            return(View(baseWord));
        }
Exemplo n.º 9
0
        public IHttpActionResult DeleteBaseWord(int id)
        {
            BaseWord baseWord = db.BaseWords.Find(id);

            if (baseWord == null)
            {
                return(NotFound());
            }

            db.BaseWords.Remove(baseWord);
            db.SaveChanges();

            return(Ok(baseWord));
        }
Exemplo n.º 10
0
 /// <summary>
 /// Serves as a hash function for a particular type.
 /// </summary>
 /// <returns>
 /// A hash code for the current <see cref="T:System.Object"/>.
 /// </returns>
 public override int GetHashCode()
 {
     return(Suffix.GetHashCode() + BaseWord.GetHashCode());
 }