Esempio n. 1
0
        public ActionResult Create(AddrBk_Relation addrbk_relation, Guid organizationId, String orgName, bool isOrganization = true)
        {
            try
            {
                if (isOrganization)
                {
                    if (addrbk_relation.RelatedExtOrgID == null || addrbk_relation.RelatedExtOrgID == Guid.Empty || addrbk_relation.RelnToPrimaryExtOrg_LCID == null || addrbk_relation.RelnToPrimaryExtOrg_LCID == Guid.Empty)
                        throw new Exception();
                }
                else
                {
                    if (addrbk_relation.RelatedIndivID == null || addrbk_relation.RelatedIndivID == Guid.Empty || addrbk_relation.RelnToPrimaryIndiv_LCID == null || addrbk_relation.RelnToPrimaryIndiv_LCID == Guid.Empty)
                        throw new Exception();
                }

                addrbk_relation.Id = Guid.NewGuid();
                if (isOrganization)
                    addrbk_relation.ContactBasis_LCID = Utils.GetOrganizationContactBasisId(organizationId);
                else
                    addrbk_relation.ContactBasis_LCID = Utils.GetLookUpBasisId(false);
                addrbk_relation.CreatedDt = addrbk_relation.LastUpdatedDt = DateTime.Now;
                addrbk_relation.ActiveRec = true;

                if (isOrganization)
                    addrbk_relation.PrimaryExtOrgID = organizationId;
                else
                    addrbk_relation.PrimaryIndivID = organizationId;

                db.AddrBk_Relation.Add(addrbk_relation);
                db.SaveChanges();

                return RedirectToAction("Index", new { organizationId = organizationId, orgName = orgName, isOrganization = isOrganization });
            }
            catch
            {
                ModelState.AddModelError(String.Empty, Utils.errorMsg);
            }

            var contactBasisId = Utils.GetOrganizationLookUpBasisId(true);

            ViewBag.isOrganization = Convert.ToString(isOrganization);
            ViewBag.orgName = orgName;
            ViewBag.organizationId = organizationId;
            ViewBag.MainTitle = Utils.AddrBkRelation + " / " + orgName;
            ViewBag.RelatedExtOrgID = new SelectList(db.AddrBk_OrganizationUnit.Where(a => a.ActiveRec == true && a.Id != organizationId && a.ContactBasis_LCID == contactBasisId), "Id", "Name", addrbk_relation.RelatedExtOrgID);
            ViewBag.RelatedIndivID = new SelectList(db.AddrBk_Person.Where(a => a.ActiveRec == true && a.Id != organizationId), "Id", "FName", addrbk_relation.RelatedIndivID);
            ViewBag.RelnToPrimaryIndiv_LCID = new SelectList(db.Lookup_GenderRelationship.Where(a => a.ActiveRec == true && a.TblColSel == Utils.AB_RelationIndiv), "Id", "Title", addrbk_relation.RelnToPrimaryIndiv_LCID);
            ViewBag.RelnToPrimaryExtOrg_LCID = new SelectList(db.Lookup_AddrBk.Where(a => a.ActiveRec == true && a.TblColSel == Utils.AB_RelationOrg), "Id", "Title", addrbk_relation.RelnToPrimaryExtOrg_LCID);

            if (isOrganization)
                return PartialView("_CreateOrg", addrbk_relation);
            else
                return PartialView("_CreateIndv", addrbk_relation);
        }
Esempio n. 2
0
        //
        // GET: /AddrBkRelation/Create
        public ActionResult Create(Guid organizationId, String orgName, bool isOrganization = true)
        {
            var contactBasisId = Utils.GetOrganizationLookUpBasisId(true);

            ViewBag.isOrganization = Convert.ToString(isOrganization);
            ViewBag.orgName = orgName;
            ViewBag.organizationId = organizationId;
            ViewBag.MainTitle = Utils.AddrBkRelation + " / " + orgName;
            ViewBag.RelatedExtOrgID = new SelectList(db.AddrBk_OrganizationUnit.Where(a => a.ActiveRec == true && a.Id != organizationId && a.ContactBasis_LCID == contactBasisId), "Id", "Name");
            ViewBag.RelatedIndivID = new SelectList(db.AddrBk_Person.Where(a => a.ActiveRec == true && a.Id != organizationId), "Id", "FName");
            ViewBag.RelnToPrimaryIndiv_LCID = new SelectList(db.Lookup_GenderRelationship.Where(a => a.ActiveRec == true && a.TblColSel == Utils.AB_RelationIndiv), "Id", "Title");
            ViewBag.RelnToPrimaryExtOrg_LCID = new SelectList(db.Lookup_AddrBk.Where(a => a.ActiveRec == true && a.TblColSel == Utils.AB_RelationOrg), "Id", "Title");

            AddrBk_Relation addrbk_relation = new AddrBk_Relation();
            addrbk_relation.EffDt = DateTime.Now;

            if (isOrganization)
                return PartialView("_CreateOrg", addrbk_relation);
            else
                return PartialView("_CreateIndv", addrbk_relation);
        }
Esempio n. 3
0
        public ActionResult Edit(AddrBk_Relation addrbk_relation, Guid organizationId, String orgName, bool isOrganization = true)
        {
            try
            {
                if (isOrganization)
                {
                    if (addrbk_relation.RelatedExtOrgID == null || addrbk_relation.RelatedExtOrgID == Guid.Empty || addrbk_relation.RelnToPrimaryExtOrg_LCID == null || addrbk_relation.RelnToPrimaryExtOrg_LCID == Guid.Empty)
                        throw new Exception();
                }
                else
                {
                    if (addrbk_relation.RelatedIndivID == null || addrbk_relation.RelatedIndivID == Guid.Empty || addrbk_relation.RelnToPrimaryIndiv_LCID == null || addrbk_relation.RelnToPrimaryIndiv_LCID == Guid.Empty)
                        throw new Exception();
                }

                addrbk_relation.LastUpdatedDt = DateTime.Now;
                db.Entry(addrbk_relation).State = EntityState.Modified;
                db.SaveChanges();

                return RedirectToAction("Index", new { organizationId = organizationId, orgName = orgName, isOrganization = isOrganization });
            }
            catch (DbUpdateConcurrencyException ex)
            {
                var entry = ex.Entries.Single();
                var databaseValues = (AddrBk_Relation)entry.GetDatabaseValues().ToObject();
                ModelState.AddModelError(string.Empty, Utils.concurrencyMsg);
                addrbk_relation.Concurrency = databaseValues.Concurrency;
            }
            catch
            {
                ModelState.AddModelError(String.Empty, Utils.errorMsg);
            }

            var contactBasisId = Utils.GetOrganizationLookUpBasisId(true);

            ViewBag.isOrganization = Convert.ToString(isOrganization);
            ViewBag.orgName = orgName;
            ViewBag.organizationId = organizationId;
            ViewBag.MainTitle = Utils.AddrBkRelation + " / " + orgName;
            ViewBag.RelatedExtOrgID = new SelectList(db.AddrBk_OrganizationUnit.Where(a => a.ActiveRec == true && a.Id != organizationId && a.ContactBasis_LCID == contactBasisId), "Id", "Name", addrbk_relation.RelatedExtOrgID);
            ViewBag.RelatedIndivID = new SelectList(db.AddrBk_Person.Where(a => a.ActiveRec == true && a.Id != organizationId), "Id", "FName", addrbk_relation.RelatedIndivID);
            ViewBag.RelnToPrimaryIndiv_LCID = new SelectList(db.Lookup_GenderRelationship.Where(a => a.ActiveRec == true && a.TblColSel == Utils.AB_RelationIndiv), "Id", "Title", addrbk_relation.RelnToPrimaryIndiv_LCID);
            ViewBag.RelnToPrimaryExtOrg_LCID = new SelectList(db.Lookup_AddrBk.Where(a => a.ActiveRec == true && a.TblColSel == Utils.AB_RelationOrg), "Id", "Title", addrbk_relation.RelnToPrimaryExtOrg_LCID);

            if (isOrganization)
                return PartialView("_EditOrg", addrbk_relation);
            else
                return PartialView("_EditIndv", addrbk_relation);
        }
Esempio n. 4
0
        // GET: /AddrBkRelation/CreateDept
        public ActionResult CreateDept(Guid organizationId, String orgName)
        {
            var contactBasisId = Utils.GetOrganizationLookUpBasisId(false);

            ViewBag.orgName = orgName;
            ViewBag.organizationId = organizationId;
            ViewBag.MainTitle = Utils.AddrbkDepartment + " / " + orgName;

            AddrBk_Relation addrbk_relation = new AddrBk_Relation();
            addrbk_relation.EffDt = DateTime.Now;

            AddrBk_Department addrbk_department = new AddrBk_Department();
            AddrBk_OrganizationUnit addrbk_organizationunit = new AddrBk_OrganizationUnit();

            addrbk_department.Addrbk_OrganizationUnit = addrbk_organizationunit;
            addrbk_department.Addrbk_Relation = addrbk_relation;
            addrbk_department.Lookup_AddrBks = db.Lookup_AddrBk.Where(a => a.ActiveRec == true && a.TblColSel == Utils.AB_RelationDept).ToList();
            addrbk_department.Lookup_ContactTypes = db.Lookup_ContactType.Where(a => a.ActiveRec == true && a.TblColSel == Utils.AB_RelationContactType && a.ContactBasis_LCID == contactBasisId).ToList();

               return PartialView("_CreateDept", addrbk_department);
        }