//
        // GET: /Organization/Create
        public ActionResult Create()
        {
            Guid contactBasisId = Utils.GetOrganizationLookUpBasisId(true);
            ViewBag.MainTitle = Utils.AddressBook + " / " + Utils.AddrBkOrganizationUnit;
            ViewBag.OUType_LCID = new SelectList(db.Lookup_ContactType.Where(e => e.ActiveRec == true && e.TblColSel == Utils.AB_OrganizationUnitType && e.ContactBasis_LCID == contactBasisId), "Id", "Title");

            var addrbk_organizationunit = new AddrBk_OrganizationUnit();
            addrbk_organizationunit.EffDt = DateTime.Now;
            return View(addrbk_organizationunit);
        }
        public ActionResult Create(AddrBk_OrganizationUnit addrbk_organizationunit)
        {
            try
            {
                addrbk_organizationunit.Id = Guid.NewGuid();
                addrbk_organizationunit.ContactBasis_LCID = Utils.GetOrganizationLookUpBasisId(true);
                addrbk_organizationunit.CreatedDt = addrbk_organizationunit.LastUpdatedDt = DateTime.Now;
                addrbk_organizationunit.ActiveRec = true;
                addrbk_organizationunit.IsProspect = false;
                db.AddrBk_OrganizationUnit.Add(addrbk_organizationunit);
                db.SaveChanges();
                return RedirectToAction("Index");
            }
            catch (Exception)
            {
                ModelState.AddModelError(string.Empty, Utils.errorMsg);

            }

            Guid contactBasisId = Utils.GetOrganizationLookUpBasisId(true);
            ViewBag.MainTitle = Utils.AddressBook + " / " + Utils.AddrBkOrganizationUnit;
            ViewBag.OUType_LCID = new SelectList(db.Lookup_ContactType.Where(e => e.ActiveRec == true && e.TblColSel == Utils.AB_OrganizationUnitType && e.ContactBasis_LCID == contactBasisId), "Id", "Title", addrbk_organizationunit.OUType_LCID);
            return View(addrbk_organizationunit);
        }
Ejemplo n.º 3
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);
        }
        public ActionResult Edit(AddrBk_OrganizationUnit addrbk_organizationunit)
        {
            try
            {
                addrbk_organizationunit.LastUpdatedDt = DateTime.Now;
                db.Entry(addrbk_organizationunit).State = EntityState.Modified;
                db.SaveChanges();
                return RedirectToAction("Index");
            }
            catch (DbUpdateConcurrencyException ex)
            {
                var entry = ex.Entries.Single();
                var databaseValues = (AddrBk_OrganizationUnit)entry.GetDatabaseValues().ToObject();
                var clientValues = (AddrBk_OrganizationUnit)entry.Entity;
                ModelState.AddModelError(string.Empty, Utils.concurrencyMsg);
                addrbk_organizationunit.Concurrency = databaseValues.Concurrency;
            }
            catch (Exception)
            {
                ModelState.AddModelError(string.Empty, Utils.errorMsg);

            }

            Guid contactBasisId = Utils.GetOrganizationLookUpBasisId(true);
            ViewBag.MainTitle = Utils.AddressBook + " / " + Utils.AddrBkOrganizationUnit + " / " + addrbk_organizationunit.Name;
            ViewBag.OUType_LCID = new SelectList(db.Lookup_ContactType.Where(e => e.ActiveRec == true && e.TblColSel == Utils.AB_OrganizationUnitType && e.ContactBasis_LCID == contactBasisId), "Id", "Title", addrbk_organizationunit.OUType_LCID);
            return View(addrbk_organizationunit);
        }