public ActionResult Create(int id, FormCollection form)
        {
            var claimPartSvc = new ClaimPartLogic(Ticket);
            var partSvc = new PartLogic(Ticket);
            var partTypeSvc = new PartTypeLogic(Ticket);

            var partId = StringUtility.ToInt(form["partId"]);
            var partTypeId = StringUtility.ToInt(form["partTypeId"]);

            var partObj = partSvc.GetById(partId);
            var partTypeObj = partTypeSvc.GetById(partTypeId);

            var obj = new ClaimPartEntity();
            obj.ClaimId = id;
            if (partObj != null)
            {
                obj.Part.Id = partObj.Id;
                obj.Part.Code = partObj.Code;
                obj.Part.Name = partObj.Name;
            }
            if (partTypeObj != null)
            {
                obj.PartType.Id = partTypeObj.Id;
                obj.PartType.Code = partTypeObj.Code;
                obj.PartType.Name = partTypeObj.Name;
            }
            obj.ReferenceNumber = form["referenceNumber"];
            obj.PurchaseDate = StringUtility.ToDateTime(form["purchaseDate"]);
            obj.Quantity = StringUtility.ToDecimal(form["quantity"]);

            claimPartSvc.Save(obj);

            return RedirectToAction("Display", "WarrantyClaim", new { id = obj.ClaimId });
        }
        public ActionResult Create(int id)
        {
            var obj = new ClaimPartEntity();
            obj.ClaimId = id;

            ViewData.Model = obj;
            ViewData["partTypeId"] = BuildPartTypeList(obj.PartType.Id);

            return View();
        }
예제 #3
0
        public void Save(ClaimPartEntity obj)
        {
            using (var db = CreateCatalog())
            {
                decimal discountPercent = 0;
                decimal partAmount = GetPartPrice(obj.ClaimId, obj.Part.Id, obj.PartType.Code, obj.PurchaseDate, out discountPercent);

                obj.DiscountPercent = discountPercent;
                obj.UnitAmount = partAmount;
                obj.ItemAmount = Math.Round(partAmount * obj.Quantity, 2);

                db.ClaimParts.Save(obj);
            }
        }