Ejemplo n.º 1
0
        public ActionResult Add(LegalEntityBranchView legalEntityBranchView, FormCollection form, int?legalEntityFK)
        {
            if (ModelState.IsValid)
            {
                ILegalEntityBranchesRepository legalEntityBranchesRepository = new LegalEntityBranchesRepository(db);
                LegalEntityBranch legalEntityBranch = new LegalEntityBranch();

                legalEntityBranchView.ConvertTo(legalEntityBranchView, legalEntityBranch);

                legalEntityBranchesRepository.Add(legalEntityBranch);
                legalEntityBranchesRepository.SaveChanges();

                TempData["message"] = LayoutHelper.GetMessage("INSERT", legalEntityBranch.LegalEntityBranchPK);

                if (TempData["legalEntityFK"] != null)
                {
                    return(RedirectToAction("Index", "LegalEntity"));
                }
                else
                {
                    return(RedirectToAction("Index", "LegalEntityBranch"));
                }
            }
            else
            {
                legalEntityBranchView.BindDDLs(legalEntityBranchView, db);

                return(View(legalEntityBranchView));
            }
        }
Ejemplo n.º 2
0
        public ActionResult Delete(int?legalEntityBranchPK)
        {
            ILegalEntityBranchesRepository legalEntityBranchesRepository = new LegalEntityBranchesRepository(db);

            if (legalEntityBranchPK != null)
            {
                LegalEntityBranch legalEntityBranch = legalEntityBranchesRepository.GetLegalEntityBranchByPK((int)legalEntityBranchPK);

                legalEntityBranch.Deleted = true;

                legalEntityBranchesRepository.SaveChanges();

                TempData["message"] = LayoutHelper.GetMessage("DELETE", legalEntityBranch.LegalEntityBranchPK);
            }

            return(Redirect(Request.UrlReferrer.AbsoluteUri));
        }
Ejemplo n.º 3
0
 public void ConvertTo(LegalEntityBranchView legalEntityBranchView, LegalEntityBranch legalEntityBranch)
 {
     legalEntityBranch.LegalEntityBranchPK = legalEntityBranchView.LegalEntityBranchPK;
     legalEntityBranch.Name            = legalEntityBranchView.Name;
     legalEntityBranch.LegalEntityFK   = legalEntityBranchView.LegalEntityFK;
     legalEntityBranch.CountryFK       = legalEntityBranchView.CountryFK;
     legalEntityBranch.CountyFK        = legalEntityBranchView.CountyFK;
     legalEntityBranch.CityCommunityFK = legalEntityBranchView.CityCommunityFK;
     legalEntityBranch.PostalOfficeFK  = legalEntityBranchView.PostalOfficeFK;
     legalEntityBranch.PlaceFK         = legalEntityBranchView.PlaceFK;
     legalEntityBranch.StreetName      = legalEntityBranchView.StreetName;
     legalEntityBranch.Phone           = legalEntityBranchView.Phone;
     legalEntityBranch.Fax             = legalEntityBranchView.Fax;
     legalEntityBranch.Mobile          = legalEntityBranchView.Mobile;
     legalEntityBranch.EMail           = legalEntityBranchView.EMail;
     legalEntityBranch.ChangeDate      = legalEntityBranchView.ChangeDate;
     legalEntityBranch.Deleted         = legalEntityBranchView.Deleted;
 }
Ejemplo n.º 4
0
        public ActionResult Edit(int?legalEntityBranchPK)
        {
            if (legalEntityBranchPK != null)
            {
                ILegalEntityBranchesRepository legalEntityBranchesRepository = new LegalEntityBranchesRepository(db);
                LegalEntityBranch     branch = legalEntityBranchesRepository.GetLegalEntityBranchByPK((int)legalEntityBranchPK);
                LegalEntityBranchView legalEntityBranchView = new LegalEntityBranchView();

                legalEntityBranchView.ConvertFrom(branch, legalEntityBranchView, db);
                legalEntityBranchView.BindDDLs(legalEntityBranchView, db);

                return(View(legalEntityBranchView));
            }
            else
            {
                return(RedirectToAction("Index", "LegalEntityBranch"));
            }
        }
Ejemplo n.º 5
0
        public ActionResult Edit(LegalEntityBranchView legalEntityBranchView, FormCollection form)
        {
            if (ModelState.IsValid)
            {
                ILegalEntityBranchesRepository legalEntityBranchesRepository = new LegalEntityBranchesRepository(db);
                LegalEntityBranch legalEntityBranch = legalEntityBranchesRepository.GetLegalEntityBranchByPK((int)legalEntityBranchView.LegalEntityBranchPK);
                legalEntityBranchView.ConvertTo(legalEntityBranchView, legalEntityBranch);

                legalEntityBranchesRepository.SaveChanges();

                TempData["message"] = LayoutHelper.GetMessage("UPDATE", legalEntityBranch.LegalEntityBranchPK);

                return(RedirectToAction("Index", "LegalEntityBranch"));
            }
            else
            {
                legalEntityBranchView.BindDDLs(legalEntityBranchView, db);

                return(View(legalEntityBranchView));
            }
        }
Ejemplo n.º 6
0
        public void ConvertFrom(LegalEntityBranch legalEntityBranch, LegalEntityBranchView legalEntityBranchView, ObjectContext db)
        {
            legalEntityBranchView.LegalEntityBranchPK = legalEntityBranch.LegalEntityBranchPK;
            legalEntityBranchView.Name            = legalEntityBranch.Name;
            legalEntityBranchView.LegalEntityFK   = legalEntityBranch.LegalEntityFK;
            legalEntityBranchView.CountryFK       = legalEntityBranch.CountryFK;
            legalEntityBranchView.CountyFK        = legalEntityBranch.CountyFK;
            legalEntityBranchView.CityCommunityFK = legalEntityBranch.CityCommunityFK;
            legalEntityBranchView.PostalOfficeFK  = legalEntityBranch.PostalOfficeFK;
            legalEntityBranchView.PlaceFK         = legalEntityBranch.PlaceFK;
            legalEntityBranchView.StreetName      = legalEntityBranch.StreetName;
            legalEntityBranchView.Phone           = legalEntityBranch.Phone;
            legalEntityBranchView.Fax             = legalEntityBranch.Fax;
            legalEntityBranchView.Mobile          = legalEntityBranch.Mobile;
            legalEntityBranchView.EMail           = legalEntityBranch.EMail;
            legalEntityBranchView.Deleted         = legalEntityBranch.Deleted;

            ILegalEntitiesRepository legalEntitiesRepository = new LegalEntitiesRepository(db);
            LegalEntity legalEntity = legalEntitiesRepository.GetLegalEntityByPK((int)legalEntityBranchView.LegalEntityFK);

            legalEntityBranchView.LegalEntityName = legalEntity.Name + " (" + legalEntity.OIB + ")";
        }