Ejemplo n.º 1
0
        public async Task <IActionResult> Create([Bind("ProfitCentreID,ProfitCentreName,ContactNo,Mobile,Address1,Address2,Address3,TradeName,ProfitCentreType,CompanyID,Active")] ProfitCentreModel profitCentre)
        {
            var errors = ModelState.Values.SelectMany(v => v.Errors);

            if (ModelState.IsValid)
            {
                profitCentre.ProfitCentreID = Guid.NewGuid();
                await ProfitCentreService.CreateAsync(profitCentre);

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["Companies"] = new SelectList(await CompanyService.GetAllAsync(), "CompanyID", "CompanyName");
            return(View(profitCentre));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Edit(Guid id, [Bind("ProfitCentreID,ProfitCentreName,ContactNo,Mobile,Address1,Address2,Address3,TradeName,ProfitCentreType,CompanyID,Active,RowVersion")] ProfitCentreModel profitCentre)
        {
            if (id != profitCentre.ProfitCentreID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    await ProfitCentreService.UpdateAsync(profitCentre);

                    return(RedirectToAction(nameof(Index)));
                }
                catch (DbUpdateConcurrencyException)
                {
                    ViewBag.Message = "Record has been modified by someone else.";
                }
            }
            ViewData["Companies"] = new SelectList(await CompanyService.GetAllAsync(), "CompanyID", "CompanyName");
            return(View(profitCentre));
        }