Beispiel #1
0
        // [ValidateAntiForgeryToken]
        public ActionResult Create(ContractsDTO model)
        {
            var    identity = (ClaimsPrincipal)Thread.CurrentPrincipal;
            string company  = identity.Claims.Where(c => c.Type == "CompanyId")
                              .Select(c => c.Value).SingleOrDefault();
            var userId = identity.Claims.Where(c => c.Type == "UserId")
                         .Select(c => c.Value).SingleOrDefault();

            int companyID = String.IsNullOrEmpty(company) ? 0:int.Parse(company);

            model.CreatedBy    = userId;
            model.ModifiedBy   = userId;
            model.ModifiedDate = DateTime.Now;
            model.CreatedDate  = DateTime.Now;
            model.ShipperID    = companyID;
            model.IsActive     = true;
            bool isCreated = _IContractService.AddContract(model);

            if (isCreated)
            {
                return(RedirectToAction("Index", new { pipelineDuns = model.PipeDuns }));
            }
            var reqTypeList = _ImetadataRequestTypeService.GetRequestType();

            ViewBag.RequestType = reqTypeList;
            return(View(model));
        }
Beispiel #2
0
        // private Guid? UpdateNonPathedReceiptNom() { }

        private ContractsDTO AddContractOnFly(string contract, int pipelineID, int companyID, string userID, decimal fuelPercent)
        {
            ContractsDTO model = new ContractsDTO();

            model.RequestNo      = contract;
            model.FuelPercentage = fuelPercent;
            model.PipelineID     = pipelineID;
            model.CreatedBy      = userID;
            model.ModifiedBy     = model.CreatedBy;
            model.ModifiedDate   = DateTime.Now;
            model.CreatedDate    = DateTime.Now;
            model.ShipperID      = companyID;
            model.IsActive       = false;
            model.ValidUpto      = DateTime.Now.AddYears(1);
            bool isCreated = contractService.AddContract(model);

            if (isCreated)
            {
                return(model);
            }
            else
            {
                return(null);
            }
        }
Beispiel #3
0
        public ActionResult CreateContract(ContractEditViewModel model)
        {
            if (!ModelState.IsValid)
            {
                ConfigureBaseDateForContractViewModel(model);

                return(View(model));
            }

            var extensionCover = Path.GetExtension(model.Cover.FileName);

            if (!(extensionCover == ".png" || extensionCover == ".jpg"))
            {
                ConfigureBaseDateForContractViewModel(model);
                ModelState.AddModelError("", @"Extension for cover should be '.png' or '.jpg'");

                return(View(model));
            }

            var extensionFile = Path.GetExtension(model.File.FileName);

            if (extensionFile != ".pdf")
            {
                ConfigureBaseDateForContractViewModel(model);
                ModelState.AddModelError("", @"Extension for file should be '.pdf'");

                return(View(model));
            }

            model.PublisherId = new Guid(User.Identity.GetUserId());
            model.FileName    = Guid.NewGuid() + extensionFile;
            model.CoverName   = Guid.NewGuid() + extensionCover;

            model.File.SaveAs(Server.MapPath("../Storage/" + model.FileName));
            model.Cover.SaveAs(Server.MapPath("../Storage/" + model.CoverName));

            var contract = new Contract();

            Mapper.Map(model, contract);

            _contractService.AddContract(contract, model.Genres);

            var messageResult = Json("The contract was took to handling", JsonRequestBehavior.AllowGet);

            return(messageResult);
        }
 public void TestAddNullContract()
 {
     contractService.AddContract(null, null, null);
 }
        public async Task <IActionResult> AddContract([FromBody] Contracts contract)
        {
            await _contractService.AddContract(contract);

            return(Ok("Record added successfully"));
        }
 public void Create([FromBody] Contracts contract)
 {
     _contractService.AddContract(contract);
 }
 public JsonResult Post([FromBody] Contract newContract)
 {
     return(new JsonResult(_contractService.AddContract(newContract)));
 }