Example #1
0
        public ActionResult Edit(int id)
        {
            var model = new CredentialEditModel();

            if (id.IsLessThanOne())
            {
                ModelState.AddModelError("missing_id", "Missing or Invalid ID");
            }

            try
            {
                using (var db = new MySelfieEntities())
                {
                    var entity = db.Credentials.SingleOrDefault(x => x.CredentialId == id);

                    if (entity.IsNotNull())
                    {
                        model.MergeWithOtherType(entity);

                        return View(model);
                    }

                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("ex", ex);

                Logger.Log(ex.ToString());
            }

            return View(model);
        }
Example #2
0
        public ActionResult Edit(CredentialEditModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    using (var db = new MySelfieEntities())
                    {
                        var wall = db.Credentials.Where(x => x.CredentialId == model.CredentialId).FirstOrDefault();

                        wall.MergeWithOtherType(model);

                        db.SaveChanges();
                    }

                }
                catch (Exception ex)
                {
                    ModelState.AddModelError("ex", ex);

                    Logger.Log(ex.ToString());

                    return View(model);
                }

                return RedirectToRoute("credential_index_g");
            }

            return View(model);
        }