コード例 #1
0
        // GET: Calls/Create
        public ActionResult Create()
        {
            CreateViewBag();
            Call call = new Call();

            call.PersonId = GlobalVariable.GetPersonId();
            return(View(call));
        }
コード例 #2
0
        // GET: Calls/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Call call = db.Call.Find(id);

            if (call == null)
            {
                return(HttpNotFound());
            }
            else
            {
                db.Call.Remove(call);
                db.SaveChanges();
            }
            return(RedirectToAction("List", new { id = GlobalVariable.GetPersonId() }));
        }
コード例 #3
0
        public ActionResult Create(Call call)
        {
            var PersonId = GlobalVariable.GetPersonId();
            var user     = from x in db.Users where User.Identity.Name == x.UserName select x.UniqueId;
            var AppUser  = user.FirstOrDefault();

            if (PersonId != -1)
            {
                var Person1 = from x in db.Person where x.PersonId == PersonId select x;

                Person person = Person1.FirstOrDefault();
                call.CreatedBy = user.FirstOrDefault();

                call.ParentName  = person.FullName;
                call.ParentType  = person.Status;
                call.DateCreated = DateTime.Now.ToString();
                call.PersonId    = person.PersonId;


                if (ModelState.IsValid)
                {
                    db.Call.Add(call);
                    db.SaveChanges();
                    return(RedirectToAction("List", new { id = person.PersonId }));
                }
                else
                {
                    CreateViewBag();
                    return(View(call));
                }
            }
            else
            {
                CreateViewBag();
                return(RedirectToAction("List", new { id = -1 }));
            }
        }