示例#1
0
        public ActionResult Create(MasterModel masterModel)
        {
            if (ModelState.IsValid)
            {
                ModelState.Clear();

                db.tblPrimaryCaregiverdatas.Add(masterModel.Primary[0]);
                db.SaveChanges();

                int newCareGiverID = db.tblPrimaryCaregiverdatas.OrderByDescending(p => p.CareGiverID)
                    .FirstOrDefault().CareGiverID;

                foreach (var ph in masterModel.Phone)
                {
                    if (!String.IsNullOrWhiteSpace(ph.Phone))
                    {
                        ph.CareGiverID = newCareGiverID;
                        db.tblPhones.Add(ph);
                    }

                }

                foreach (var ad in masterModel.Address)
                {
                    if (!String.IsNullOrWhiteSpace(ad.Street1))
                    {
                        ad.CareGiverID = newCareGiverID;
                        db.tblAddresses.Add(ad);
                    }

                }

                foreach (var em in masterModel.Email)
                {
                    if (!String.IsNullOrWhiteSpace(em.EMail))
                    {
                        em.CareGiverID = newCareGiverID;
                        db.tblEmails.Add(em);
                    }
                }
                masterModel.mandatoryKey = 10;
                db.SaveChanges();
                return RedirectToAction("Index", new { id = newCareGiverID });
            }

            return View();
        }
示例#2
0
        // GET: MasterModels
        public ActionResult Index(int id)
        {
            var query = from a in db2.AspNetUsers
                        where a.Email == User.Identity.Name
                        select a;

            var firstLast = query.ToList();

            string first = firstLast[0].First;
            string last = firstLast[0].Last;

            var model = new MasterModel();

            model.Address = GetAddressList(id);
            model.Primary = GetPrimaryList(id);
            model.Email = GetEmailList(id);
            model.Phone = GetPhoneList(id);
            model.Related = GetRelatedList(id);
            model.TrainingHistory = GetTrainingHistoryList(id);
            model.InquiryReferral = GetInquiryReferralList(id);
            model.Communication = GetCommunication(id);

            model.First = first;
            model.Last = last;

            ViewBag.PhoneType = new SelectList(db.tlkpPhoneTypes, "ID", "Descr");
            ViewBag.AddressType = new SelectList(db.tlkpAddressTypes, "ID", "Descr");
            ViewBag.EmailType = new SelectList(db.tlkpEmailTypes, "ID", "Descr");
            ViewBag.HeardAboutType = new SelectList(db.tlkpRecruitmentCategories, "id", "Descr");

            ViewBag.RelatedType = new SelectList(db.tlkpRelationships, "ID", "Descr");

            ViewBag.UserId = new SelectList(db.tblUsers, "UserId", "Last");
            //may need to include states and cities as lookup tables so they can be dropdown menus?
            return View(model);
        }
示例#3
0
        public ActionResult Index(int? id, MasterModel masterModel)
        {
            if (ModelState.IsValid)
            {
                foreach (var item in masterModel.Email)
                {
                    if (item.id != 0)
                    {
                        db.Entry(item).State = EntityState.Modified;
                    }
                    else
                    {
                        if (item.EMail != null)
                        {
                            item.CareGiverID = id;
                            db.tblEmails.Add(item);
                        }
                    }
                }

                foreach (var item in masterModel.Phone)
                {
                    if (item.Phone != null)
                    {
                        if (item.id != 0)
                        {
                            db.Entry(item).State = EntityState.Modified;
                        }
                        else
                        {
                            if (item.Phone.Length > 0)
                            {
                                item.CareGiverID = id;
                                db.tblPhones.Add(item);
                            }
                        }
                    }
                }

                foreach (var item in masterModel.Address)
                {
                    if (item.id != 0)
                    {
                        db.Entry(item).State = EntityState.Modified;
                    }
                    else
                    {
                        item.CareGiverID = id;
                        db.tblAddresses.Add(item);
                    }
                }
                if (masterModel.Related != null)
                {
                    foreach (var item in masterModel.Related)
                    {
                        if (item.id != 0)
                        {
                            db.Entry(item).State = EntityState.Modified;
                        }
                        else
                        {
                            if (item.FirstName.Length > 0)
                            {
                                item.CareGiverID = (int)id;
                                db.tblRelatedCaregivers.Add(item);
                            }
                        }
                    }
                }

                foreach (var item in masterModel.Communication)
                {
                    if (item.Notes != null)
                    {
                        if (item.Notes.Length > 0)
                        {
                            string emailuser = User.Identity.Name;

                            item.CareGiverID = (int)id;
                            item.CommnDate = DateTime.Now;

                            db.tblCommunications.Add(item);
                        }
                    }
                }

                foreach (var item in masterModel.TrainingHistory)
                {
                    if (item.IDTR != 0)
                    {
                        db.Entry(item).State = EntityState.Modified;
                    }
                }

                foreach (var item in masterModel.InquiryReferral)
                {
                    if (item.IDIRS != 0)
                    {
                        db.Entry(item).State = EntityState.Modified;
                    }
                }

                foreach (var item in masterModel.Primary)
                {

                    db.Entry(item).State = EntityState.Modified;
                }

                db.SaveChanges();
                return Redirect("../Index/" + id.ToString());
            }
            return View(masterModel);
        }
示例#4
0
        public ActionResult Edit(int id)
        {
            var model = new MasterModel();

            model.Address = GetAddressList(id);
            model.Primary = GetPrimaryList(id);
            model.Email = GetEmailList(id);
            model.Phone = GetPhoneList(id);
            model.Related = GetRelatedList(id);
            model.TrainingHistory = GetTrainingHistoryList(id);
            model.InquiryReferral = GetInquiryReferralList(id);
            model.Communication = GetCommunication(id);

            ViewBag.PhoneType = new SelectList(db.tlkpPhoneTypes, "ID", "Descr");
            ViewBag.AddressType = new SelectList(db.tlkpAddressTypes, "ID", "Descr");
            ViewBag.EmailType = new SelectList(db.tlkpEmailTypes, "ID", "Descr");
            ViewBag.HeardAboutType = new SelectList(db.tlkpRecruitmentCategories, "id", "Descr");

            ViewBag.RelatedType = new SelectList(db.tlkpRelationships, "ID", "Descr");

            ViewBag.UserId = new SelectList(db.tblUsers, "UserId", "Last");
            //may need to include states and cities as lookup tables so they can be dropdown menus?
            return View(model);
        }