コード例 #1
0
        public async Task <IActionResult> Create(CustomerDetailsModel model, bool continueEditing)
        {
            try
            {
                var existingcustomer = (await _customerService.GetAllCustomerListAsync(model.EmailId, model.MobileNo1.ToString(), model.PanNo, model.AdharNo)).FirstOrDefault();
                if (existingcustomer == null)
                {
                    TempData["UserMessageError"] = "Records allready exist.";
                    return(View());
                }

                var customerInfo = new CustomerDetailsTable
                {
                    Salutation   = model.Salutation,
                    CustomerName = model.CustomerName,
                    EmailId      = model.EmailId,
                    MobileNo1    = model.MobileNo1,
                    MobileNo2    = Convert.ToDecimal(model.MobileNo2),
                    Address1     = model.Address1,
                    Address2     = model.Address2,
                    Pin          = model.Pin,
                    Taluka       = model.Taluka,
                    District     = model.District,
                    State        = model.StateId,
                    PanNo        = model.PanNo,
                    AdharNo      = model.AdharNo,
                    Gstno        = model.Gstno,
                    DateUpdated  = DateTime.UtcNow,
                    DateCreated  = DateTime.UtcNow
                };

                await _customerService.InsertAsync(customerInfo);

                if (continueEditing)
                {
                    return(RedirectToAction(nameof(Edit), new { id = customerInfo.Id }));
                }

                TempData["UserMessageSuccess"] = "Record saved sucessfully.";
                return(RedirectToAction(nameof(List)));
            }
            catch (Exception ex)
            {
                TempData["UserMessageError"] = ex.Message.ToString();
                return(RedirectToAction(nameof(Create)));
            }
        }
コード例 #2
0
 public async Task DeleteAsync(CustomerDetailsTable entity)
 {
     await _customerRepo.RemoveAsync(entity);
 }
コード例 #3
0
 public async Task UpdateAsync(CustomerDetailsTable entity)
 {
     await _customerRepo.UpdateAsync(entity);
 }
コード例 #4
0
 public async Task InsertAsync(CustomerDetailsTable entity)
 {
     await _customerRepo.AddAsync(entity);
 }
コード例 #5
0
        public async Task <IActionResult> GenarateQuote(GenerateQuotationModel model, IFormCollection form)
        {
            decimal totalAmount = 0;
            var     custId      = Convert.ToInt32(form["CustId"]);
            var     varientInfo = _varientMasterService.GetVarientByIdAsync(model.VarientId);
            var     priceList   = await _priceListMasterService.GetModelPriceByModelCodeAsync(varientInfo.VarientCode, varientInfo.VerientName, model.VarientType);

            if (priceList != null)
            {
                model.CustomerDetails.CustomerName = form["CustomerName"].ToString();
                model.CustomerDetails.Address1     = form["Address1"].ToString();
                model.CustomerDetails.Address2     = !string.IsNullOrEmpty(form["Address2"].ToString()) ? form["Address2"].ToString() : string.Empty;
                model.CustomerDetails.EmailId      = form["EmailId"].ToString();
                model.CustomerDetails.Pin          = form["Pin"].ToString();
                model.CustomerDetails.MobileNo1    = Convert.ToDecimal(form["MobileNo1"]);
                model.CustomerDetails.MobileNo2    = Convert.ToDecimal(form["MobileNo2"]);

                var custInfo = await _customerService.GetAllCustomerByIdAsync(custId);

                if (custInfo == null)
                {
                    //create cust entry
                    var customer = new CustomerDetailsTable
                    {
                        CustomerName = form["CustomerName"],
                        Address1     = form["Address1"],
                        Address2     = !string.IsNullOrEmpty(form["Address2"].ToString()) ? form["Address2"].ToString() : string.Empty,
                        EmailId      = form["EmailId"],
                        Pin          = form["Pin"],
                        Taluka       = form["Taluka"],
                        District     = form["District"],
                        State        = Convert.ToInt32(form["StateId"]),
                        MobileNo1    = Convert.ToDecimal(form["MobileNo1"]),
                        MobileNo2    = Convert.ToDecimal(form["MobileNo2"]),
                        DateUpdated  = DateTime.UtcNow,
                        DateCreated  = DateTime.UtcNow
                    };
                    await _customerService.InsertAsync(customer);

                    custId = customer.Id;
                }

                //add quotation info
                var quotation = new QuotationDetails
                {
                    BranchId      = 1,
                    ModelId       = model.ModelId,
                    VarientId     = model.VarientId,
                    VarientType   = model.VarientType,
                    ColourId      = model.VarientColourId,
                    CustomerId    = custId,
                    ScId          = model.SalesConsultantId,
                    LeadSource    = model.SourceOfEnquiry,
                    BookingAmount = model.BookingAmount,
                    DateCretaed   = DateTime.UtcNow,
                    CreatedBy     = Convert.ToInt32(HttpContext.User.FindFirst(claim => claim.Type == System.Security.Claims.ClaimTypes.NameIdentifier)?.Value)
                };
                await _quotationManagerService.InsertAsync(quotation);

                //prepare quote model
                model.QuoteDate = DateTime.UtcNow.ToString("dd/MM/yyyy");
                model.quoteNo   = quotation.Id;
                var scInfo = await _userMasterService.GetUserByIdAsync(model.SalesConsultantId);

                model.ModelName      = _modelsMasterService.GetModelbyIdAsync(model.ModelId).ModelName;
                model.VarientName    = varientInfo.VerientName;
                model.ColourName     = _colourMasterService.GetColourByIdAsync(model.VarientColourId).ColourName;
                model.SCName         = scInfo.FirstName + " " + scInfo.LastName;
                model.SCMobileNumber = scInfo.ContactNumber.ToString();
                var tlInfo = await _userMasterService.GetUserByIdAsync(model.TeamLeaderId);

                model.TLName = tlInfo.FirstName + " " + tlInfo.LastName;

                if (Convert.ToBoolean(form["Ex Showroom Price"]))
                {
                    model.VehiclePriceList.ExShowroomPrice = Convert.ToDecimal(priceList.ExShowroomPrice);
                    totalAmount += Convert.ToDecimal(priceList.ExShowroomPrice);
                }

                if (Convert.ToBoolean(form["Fast Tag"]))
                {
                    model.VehiclePriceList.FastTag = Convert.ToDecimal(priceList.FastTag);
                    totalAmount += Convert.ToDecimal(priceList.FastTag);
                }

                if (Convert.ToBoolean(form["TCS"]))
                {
                    model.VehiclePriceList.TCS = Convert.ToDecimal(priceList.Tcs);
                    totalAmount += Convert.ToDecimal(priceList.Tcs);
                }

                if (Convert.ToBoolean(form["Honda Assure Insurance"]))
                {
                    model.VehiclePriceList.Insurance = Convert.ToDecimal(priceList.Hainsurance);
                    totalAmount += Convert.ToDecimal(priceList.Hainsurance);
                }

                if (Convert.ToBoolean(form["Honda Assure Insurance + Key Protect"]))
                {
                    model.VehiclePriceList.InsuranceWithKeyProtect = Convert.ToDecimal(priceList.HanilDepWithKeyProtect);
                    totalAmount += Convert.ToDecimal(priceList.HanilDepWithKeyProtect);
                }

                if (Convert.ToBoolean(form["Honda Assure Insurance + Engine Protect"]))
                {
                    model.VehiclePriceList.InsuranceWithEngineProtect = Convert.ToDecimal(priceList.HartiwithEngineProtect);
                    totalAmount += Convert.ToDecimal(priceList.HartiwithEngineProtect);
                }

                if (Convert.ToBoolean(form["Registration (Indv/Comp)"]))
                {
                    model.VehiclePriceList.Registration = Convert.ToDecimal(priceList.Rtoindividual);
                    totalAmount += Convert.ToDecimal(priceList.Rtoindividual);
                }

                if (Convert.ToBoolean(form["Accessory Combo Kit"]))
                {
                    model.VehiclePriceList.Accessories = Convert.ToDecimal(priceList.AccessoryComboKit);
                    totalAmount += Convert.ToDecimal(priceList.AccessoryComboKit);
                }

                if (Convert.ToBoolean(form["Extended Warranty"]))
                {
                    model.VehiclePriceList.ExtendedWarranty = Convert.ToDecimal(priceList.ExtendedWarranty);
                    totalAmount += Convert.ToDecimal(priceList.ExtendedWarranty);
                }

                if (Convert.ToBoolean(form["RSA"]))
                {
                    model.VehiclePriceList.RSA = Convert.ToDecimal(priceList.Rsa);
                    totalAmount += Convert.ToDecimal(priceList.Rsa);
                }

                if (Convert.ToBoolean(form["Clay Bar"]))
                {
                    model.VehiclePriceList.ClayBar = Convert.ToDecimal(priceList.ClayBar);
                    totalAmount += Convert.ToDecimal(priceList.ClayBar);
                }

                if (Convert.ToBoolean(form["Antirust"]))
                {
                    model.VehiclePriceList.Antirust = Convert.ToDecimal(priceList.Antirust);
                    totalAmount += Convert.ToDecimal(priceList.Antirust);
                }

                if (Convert.ToBoolean(form["Carpet Lamination"]))
                {
                    model.VehiclePriceList.Lamination = Convert.ToDecimal(priceList.CarpetLamination);
                    totalAmount += Convert.ToDecimal(priceList.CarpetLamination);
                }

                model.VehiclePriceList.Total      = totalAmount;
                model.VehiclePriceList.GrandTotal = model.VehiclePriceList.Total;

                model.Url = HttpContext.Request.Scheme + "://" + HttpContext.Request.Host.Value;

                //generate quote
                var quote = await _viewToStringRendererService.RenderToStringAsync("GenerateQuotation/QuoteTemplate", model);

                HtmlToPdf   converter = new HtmlToPdf();
                PdfDocument doc       = converter.ConvertHtmlString(quote.ToString());
                byte[]      pdf       = doc.Save();
                doc.Close();

                return(File(pdf, "application/pdf", "quote.pdf"));
            }

            model.IsErrorFound = true;
            model.Error        = "Vehicle price list not found";
            return(View(model));
        }
コード例 #6
0
        public async Task <IActionResult> CustomerVehicleAllotment(IFormCollection form)
        {
            try
            {
                var custId   = Convert.ToInt32(form["CustId"]);
                var vehId    = Convert.ToInt32(form["item.VID"]);
                var custInfo = await _customerService.GetAllCustomerByIdAsync(custId);

                if (custInfo == null)
                {
                    //create cust entry
                    var customer = new CustomerDetailsTable
                    {
                        CustomerName = form["CustomerName"],
                        Address1     = form["Address1"],
                        Address2     = !string.IsNullOrEmpty(form["Address2"].ToString()) ? form["Address2"].ToString() : string.Empty,
                        EmailId      = form["EmailId"],
                        Pin          = form["Pin"],
                        Taluka       = form["Taluka"],
                        District     = form["District"],
                        State        = Convert.ToInt32(form["StateId"]),
                        MobileNo1    = Convert.ToDecimal(form["MobileNo1"]),
                        MobileNo2    = Convert.ToDecimal(form["MobileNo2"]),
                        DateUpdated  = DateTime.UtcNow,
                        DateCreated  = DateTime.UtcNow
                    };
                    await _customerService.InsertAsync(customer);

                    custId = customer.Id;
                }

                //add record in table
                if (vehId != 0)
                {
                    var vehicleAllotDetails = new VehicleAllotmentDetails
                    {
                        VehicleId   = Convert.ToInt32(form["item.VID"]),
                        CustomerId  = custId,
                        ModelId     = Convert.ToInt32(form["ModelId"]),
                        VarientId   = Convert.ToInt32(form["VarientId"]),
                        ColourId    = Convert.ToInt32(form["VarientColourId"]),
                        VarientType = form["VarientType"],
                        Scid        = Convert.ToInt32(form["SalesConsultantId"]),
                        BranchId    = Convert.ToInt32(form["BranchId"]),
                        DateCreated = DateTime.UtcNow,
                        DateUpdated = DateTime.UtcNow,
                        AllotedBy   = Convert.ToInt32(HttpContext.User.FindFirst(claim => claim.Type == System.Security.Claims.ClaimTypes.NameIdentifier)?.Value),
                    };
                    await _vehicleAllotmentService.InsertAsync(vehicleAllotDetails);

                    //update vehicle status in vehicle master
                    var vehicle = await _vehicleMasterService.GetByIdAsync(vehId);

                    if (vehicle != null)
                    {
                        vehicle.TrackStatus = vehicleAllotDetails.IsAlloted ? VehicleStatusEnum.Alloted.ToString() : VehicleStatusEnum.PartiallyAlloted.ToString();
                        vehicle.DateUpdated = DateTime.UtcNow;
                        await _vehicleMasterService.UpdateAsync(vehicle);
                    }
                }

                return(RedirectToAction("Index", "Home"));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }