Пример #1
0
        public override System.Web.Mvc.ActionResult Edit(Models.Branch Branch)
        {
            var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.Edit);

            ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "Branch", Branch);
            EditOverride(callInfo, Branch);
            return(callInfo);
        }
 public ActionResult Add(Models.Branch branch)
 {
     if (ModelState.IsValid)
     {
         DataAccessLayerCommon.Branch Branch = branchMapper.MapFromModel(branch);
         branchRepository.Insert(Branch);
         return(RedirectPermanent("/branch/showall"));
     }
     return(View());
 }
 public ActionResult Edit(Models.Branch branch, int id)
 {
     if (ModelState.IsValid)
     {
         DataAccessLayerCommon.Branch Branch = branchMapper.MapFromModel(branch);
         branchRepository.Update(id, Branch);
         return(RedirectPermanent("/branch/showall"));
     }
     return(View(branch));
 }
Пример #4
0
        public DataAccessLayerCommon.Branch MapFromModel(Models.Branch branch)
        {
            DataAccessLayerCommon.Branch tempBranch = new DataAccessLayerCommon.Branch
            {
                Id   = branch.Id,
                Name = branch.Name
            };

            ConcatAddress(tempBranch, branch);
            return(tempBranch);
        }
Пример #5
0
        public Models.Branch MapFromEntity(DataAccessLayerCommon.Branch branch)
        {
            Models.Branch tempBranch = new Models.Branch
            {
                Id   = branch.Id,
                Name = branch.Name
            };
            SplitAddress(branch.Address, tempBranch);

            return(tempBranch);
        }
        public ActionResult ShowAll()
        {
            IEnumerable <DataAccessLayerCommon.Branch> branches = branchRepository.GetList();
            List <Models.Branch> branchModels = new List <Models.Branch>();

            foreach (DataAccessLayerCommon.Branch b in branches)
            {
                Models.Branch tempBranch = branchMapper.MapFromEntity(b);
                branchModels.Add(tempBranch);
            }
            return(View(branchModels));
        }
Пример #7
0
        private void SplitAddress(string address, Models.Branch branch)
        {
            string[] addressArray = address.Split(',');

            branch.Country = addressArray[0];
            branch.City    = addressArray[1];
            branch.Street  = "";
            for (int x = 2; x < addressArray.Length; x++)
            {
                branch.Street += addressArray[x];
            }
        }
Пример #8
0
 public static Tbl_Branch MapFrom(this Models.Branch branch)
 {
     return(new Tbl_Branch
     {
         Id = branch.Id,
         Name = branch.Name,
         Email = branch.Email,
         Phone = branch.Phone,
         TaxNumber = branch.TaxNumber,
         Address = branch.Address,
         Logo = branch.Logo
     });
 }
Пример #9
0
        public virtual System.Web.Mvc.ActionResult Create(Models.Branch Branch)
        {
            if (ModelState.IsValid)
            {
                UnitOfWork.BranchRepository.Insert(Branch);

                UnitOfWork.Save();

                return(RedirectToAction(MVC.Branch.Index()));
            }

            return(View(Branch));
        }
Пример #10
0
        public virtual System.Web.Mvc.ActionResult DeleteConfirmed(System.Guid id)
        {
            Models.Branch oBranch =
                UnitOfWork.BranchRepository.Get()
                .Where(current => current.Id == id)
                .FirstOrDefault()
            ;

            UnitOfWork.BranchRepository.Delete(oBranch);

            UnitOfWork.Save();

            return(RedirectToAction(MVC.Branch.AdminIndex()));
        }
Пример #11
0
        public virtual System.Web.Mvc.ActionResult Edit(System.Guid id)
        {
            Models.Branch oBranch =
                UnitOfWork.BranchRepository.Get()
                .Where(current => current.Id == id)
                .FirstOrDefault()
            ;

            if (oBranch == null)
            {
                return(HttpNotFound());
            }

            return(View(oBranch));
        }
Пример #12
0
        public virtual System.Web.Mvc.ActionResult Edit(Models.Branch Branch)
        {
            Branch.UpdateDateTime = Infrastructure.Utility.Now;

            if (ModelState.IsValid)
            {
                UnitOfWork.BranchRepository.Update(Branch);

                UnitOfWork.Save();

                return(RedirectToAction(MVC.Branch.AdminIndex()));
            }

            return(View(Branch));
        }
Пример #13
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Branch = await _context.Branch
                     .Include(b => b.Company).FirstOrDefaultAsync(m => m.BranchID == id);

            if (Branch == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Пример #14
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Branch = await _context.Branch.FindAsync(id);

            if (Branch != null)
            {
                _context.Branch.Remove(Branch);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
Пример #15
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Branch = await _context.Branch
                     .Include(b => b.Company).FirstOrDefaultAsync(m => m.BranchID == id);

            if (Branch == null)
            {
                return(NotFound());
            }
            Img = Branch.BranchManagerSign;
            ViewData["CompanyID"] = new SelectList(_context.Company, "CompanyID", "CompanyName");
            return(Page());
        }
Пример #16
0
        public async Task <IEnumerable <Models.Branch> > GetBranchFromRepository(string url)
        {
            var branches = new List <Models.Branch>();
            await Task.Run(() =>
            {
                using (var repo = new LibGit2Sharp.Repository(url))
                {
                    foreach (LibGit2Sharp.Branch b in repo.Branches.Where(b => !b.IsRemote))
                    {
                        var branch = new Models.Branch()
                        {
                            Id = Guid.NewGuid(), Name = b.FriendlyName
                        };
                        branches.Add(branch);
                    }
                }
            });

            return(branches);
        }
        public async Task <ActionResult <Branch> > SaveBranch([FromBody] BranchDTO BranchA)
        {
            {
                string valorrespuesta = "";
                try
                {
                    Branch     BranchB    = new Branch();
                    Branch     BranchC    = new Branch();
                    string     baseadress = config.Value.urlbase;
                    HttpClient _client    = new HttpClient();
                    _client.DefaultRequestHeaders.Add("Authorization", "Bearer " + HttpContext.Session.GetString("token"));
                    var result = await _client.GetAsync(baseadress + "api/Branch/GetBranchByName/" + BranchA.BranchName);

                    if (result.IsSuccessStatusCode)
                    {
                        valorrespuesta = await(result.Content.ReadAsStringAsync());
                        BranchB        = JsonConvert.DeserializeObject <Branch>(valorrespuesta);
                        BranchC        = JsonConvert.DeserializeObject <Branch>(valorrespuesta);
                        if (BranchB != null && BranchA.BranchId == 0)
                        {
                            if (BranchB.BranchName.ToLower() == BranchA.BranchName.ToLower())
                            {
                                {
                                    return(await Task.Run(() => BadRequest($"Ya existe una sucursal con ese nombre.")));
                                }
                            }
                        }
                    }
                    result = await _client.GetAsync(baseadress + "api/Branch/GetBranchById/" + BranchA.BranchId);

                    BranchA.FechaModificacion   = DateTime.Now;
                    BranchA.UsuarioModificacion = HttpContext.Session.GetString("user");
                    if (result.IsSuccessStatusCode)
                    {
                        valorrespuesta = await(result.Content.ReadAsStringAsync());
                        BranchB        = JsonConvert.DeserializeObject <Branch>(valorrespuesta);
                    }
                    if (BranchB == null)
                    {
                        BranchB = new Models.Branch();
                    }
                    if (BranchB.BranchId == 0)
                    {
                        BranchB.FechaCreacion   = DateTime.Now;
                        BranchB.UsuarioCreacion = HttpContext.Session.GetString("user");
                        var insertresult = await Insert(BranchA);
                    }
                    else
                    {
                        if (BranchC != null)
                        {
                            if (BranchC.BranchName.ToLower() == BranchA.BranchName.ToLower() && BranchC.BranchId != BranchA.BranchId)
                            {
                                return(await Task.Run(() => BadRequest($"Ya existe una sucursal con ese nombre.")));
                            }
                        }
                        BranchA.FechaCreacion   = DateTime.Now;
                        BranchA.UsuarioCreacion = HttpContext.Session.GetString("user");
                        var updateresult = await Update(BranchA.BranchId, BranchA);
                    }
                }
                catch (Exception ex)
                {
                    _logger.LogError($"Ocurrio un error: { ex.ToString() }");
                    throw ex;
                }
                return(Json(BranchA));
            }
        }
 public ActionResult Edit(int id)
 {
     DataAccessLayerCommon.Branch branchFromCommon = branchRepository.GetItem(id);
     Models.Branch branch = branchMapper.MapFromEntity(branchFromCommon);
     return(View(branch));
 }
Пример #19
0
 partial void EditOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, Models.Branch Branch);
Пример #20
0
 private void ConcatAddress(DataAccessLayerCommon.Branch branch, Models.Branch tempBranch)
 {
     branch.Address = tempBranch.Country + "," + tempBranch.City + "," + tempBranch.Street;
 }