Ejemplo n.º 1
0
        public async Task <ActionResult> ContractsCreate(EditContractorContractsViewModel model)
        {
            if (ModelState.IsValid)
            {
                Contract contract = (Contract)model.GetContract();
                contract.ContractorID = model.ContractorID;
                contract.CustomerID   = model.CustomerID;
                try
                {
                    //contract.CreationDate = DateTime.UtcNow;
                    //contract.CreationUser = System.Web.HttpContext.Current.User.Identity.Name;
                    await contractRepository.CreateAsync(contract);

                    return(RedirectToAction("Contracts", "Contractors", new { id = model.ContractorID }));
                }
                catch (Exception e)
                {
                    var errors = string.Join(",", e.Message);
                    ModelState.AddModelError(string.Empty, errors);
                }
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
Ejemplo n.º 2
0
        public ActionResult ContractsCreate(int contractorID, int customerID)
        {
            EditContractorContractsViewModel model = new EditContractorContractsViewModel();

            model.ContractorID = contractorID;
            model.CustomerID   = customerID;
            return(View(model));
        }
Ejemplo n.º 3
0
        public async Task <ActionResult> ContractsDelete(int contractID, int contractorID)
        {
            Contract contract = await contractRepository.FindContractByIDAsync(contractID);

            if (contract == null)
            {
                return(HttpNotFound());
            }
            var model = new EditContractorContractsViewModel(contract);

            return(View(model));
        }
Ejemplo n.º 4
0
        public async Task <ActionResult> ContractsEdit(EditContractorContractsViewModel model)
        {
            if (ModelState.IsValid)
            {
                Contract contract = model.GetContract();
                try
                {
                    //Contract.ModifiedDate = DateTime.UtcNow;
                    //Contract.ModifiedUser = System.Web.HttpContext.Current.User.Identity.Name;
                    await contractRepository.UpdateAsync(contract);

                    return(RedirectToAction("Contracts", "Contractors", new { id = model.ContractorID }));
                }
                catch (Exception e)
                {
                    var errors = string.Join(",", e.Message);
                    ModelState.AddModelError(string.Empty, errors);
                }
            }

            return(View(model));
        }