Example #1
0
        public ActionResult Create([Bind(Include = "Id,Name,CreatedAt,UpdatedAt,DeletedAt,TypeStatus")] Type type)
        {
            type.Id        = Guid.NewGuid().ToString();
            type.CreatedAt = DateTime.Now;
            type.UpdatedAt = DateTime.Now;

            if (ModelState.IsValid)
            {
                db.Types.Add(type);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(type));
        }
Example #2
0
        public ActionResult Edit([Bind(Include = "Id,Name,CreatedAt,UpdatedAt,DeletedAt,TypeStatus")] Type type)
        {
            type.UpdatedAt = DateTime.Now;
            if (type.TypeStatus == Type.TypeStatusEnum.Deleted)
            {
                type.DeletedAt = DateTime.Now;
            }

            if (ModelState.IsValid)
            {
                db.Entry(type).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(type));
        }