public bool ValidService(Service ser)
 {
     return true;
 }
		private void detach_Services(Service entity)
		{
			this.SendPropertyChanging();
			entity.Contact = null;
		}
 public bool CreateService(Service ser)
 {
     try
     {
         _db.Services.InsertOnSubmit(ser);
         _db.SubmitChanges();
         return true;
     }
     catch
     {
         return false;
     }
 }
 partial void DeleteService(Service instance);
		private void attach_Services(Service entity)
		{
			this.SendPropertyChanging();
			entity.Contact = this;
		}
 partial void UpdateService(Service instance);
 partial void InsertService(Service instance);
		private void detach_Services(Service entity)
		{
			this.SendPropertyChanging();
			entity.Programme = null;
		}
		private void attach_Services(Service entity)
		{
			this.SendPropertyChanging();
			entity.Programme = this;
		}
        public ActionResult Save(int? ProgrammeID, int? LeadContactID, int? StagedPayment, int? ExtendYear,
            int? ExtendMonth, int? LimitedYear, int? LimitedMonth, decimal? continuationamount, FormCollection collection)
        {
            CultureInfo enUS = new CultureInfo("en-US");
            Service ser = new Service();
            ser.SerName = collection["ServiceName"];
            ser.SerIsActive = 1;
            ser.SerShortDescription = collection["ShortDescription"];
            ser.SerFullDescription = collection["FullDescription"];
            ser.SerSubType = collection["SubType"];
            ser.SerDeptCode = collection["DeptCode"];
            ser.LeadContactID = LeadContactID;
            ser.SerType = collection["SerType"];
            ser.ClientDescription = collection["ClientDescription"];
            ser.SerDescriptionDelivery = collection["DescriptionDelivery"];
            ser.SerAttendance = collection["Attendance"];
            ser.SerContractCode = collection["ContractCode"];
            ser.SerStartExpected = _db.ConvertDate(collection["StartExpected"], "dd/MM/yyyy");
            ser.SerContractValue = collection["ContractValue"];
            ser.SerStartDate = _db.ConvertDate(collection["StartDate"], "dd/MM/yyyy");
            ser.SerEndDate = _db.ConvertDate(collection["EndDate"], "dd/MM/yyyy");
            ser.SerReferralProcess = collection["ReferralProcess"];

            ser.SerStagedPayment = StagedPayment;
            ser.SerExtendable = (collection["Extendable"] == "1" ? 1 : 0);
            ser.SerTimeLimited = (collection["TimeLimited"] == "1" ? 1 : 0);
            ser.SerExtendYear = ser.SerExtendable == 1 ? ExtendYear : 0;
            ser.SerExtendMonth = ser.SerExtendable == 1 ? ExtendMonth : 0;
            ser.SerTimeLimitedYear = ser.SerTimeLimited == 1 ? LimitedYear : 0;
            ser.SerTimeLimitedMonth = ser.SerTimeLimited == 1 ? LimitedMonth : 0;
            ser.ProgrammeID = ProgrammeID;
            ser.OtherService = "," + collection["OtherService[]"] + ",";
            ser.SerDetail3RefList = "," + collection["SerDetail3RefList[]"] + ",";
            ser.SerDetail2RefList = ","+collection["ServiceDetail2[]"]+",";

            if (ser.SerSubType == "Contract")
            {
                ser.SerContractRefList = "," + collection["ServiceContract[]"]+",";
            }
            var re = _db.CreateService(ser);
            if (ser.SerSubType == "Funded" && re == true)
            {

                FundingDetail fund = new FundingDetail();
                fund.FundingSource = collection["fundingsource"];
                fund.FundingNeeds = collection["fundingneeds"];
                fund.FundingContractDetail = Convert.ToInt32(collection["FundingContactID"]);
                fund.FundingContinuationNeeded = collection["fundingcontinuation"] == "1" ? 1 : 0;
                if (fund.FundingContinuationNeeded == 1)
                {
                    fund.FundingContinuationAmount = continuationamount;
                    fund.FundingContinuationDetail = collection["continuationdetail"];
                }

                fund.FundingAmount = Convert.ToDecimal(collection["fundingamount"]);
                fund.FundingStart = _db.ConvertDate(collection["fundingstart"], "dd/MM/yyyy");
                fund.FundingEnd = _db.ConvertDate(collection["fundingend"], "dd/MM/yyyy");
                fund.FundraisingForText = collection["fundraisingtext"];
                fund.FundraisingNeeds = collection["fundraisingneeds"];
                fund.FundraisingRequiredBy = _db.ConvertDate(collection["fundingrequiredby"], "dd/MM/yyyy");
                fund.FundraisingWhy = collection["fundingfundraisingwhy"];
                fund.FundraisingComplete = collection["fundingcomplete"] == "1" ? 1 : 0;
                fund.FundraisingCompletedDate = fund.FundraisingComplete == 1 ? _db.ConvertDate(collection["fundingcompletedate"], "dd/MM/yyyy") : null;
                fund.FundraisingDonorAnonymous = collection["donoranonymous"] == "1" ? 1 : 0;
                fund.FundraisingDonationDate = _db.ConvertDate(collection["donationdate"], "dd/MM/yyyy");
                fund.FundraisingDonorAmount = collection["donoramount"]=="" ? new decimal?(): Convert.ToDecimal(collection["donoramount"]);
                fund.FundraisingDonationIncremental = collection["fundingincremental"] == "1" ? 1 : 0;
                fund.SerID = ser.SerID;

                _db.CreateFunding(fund);
            }

            //ViewBag.testCheckList = collection["ServiceContract[]"];
            //ViewBag.testCheck = collection["fundingcomplete"];
            //ViewBag.testDate = collection["StartExpected"];
            //ViewBag.testMoney = collection["fundingamount"];

            //ViewBag.RefFrom = "ServiceDetail2";
            //ViewBag.RefChecked = ",44,45,47";
            //ViewBag.RefFrom = "ServiceContract";
            //ViewBag.RefChecked = ",31,32,40";
            //RedirectToAction("Add","Service");
            ViewBag.Alert = "true";
            ViewBag.Message = "Action success!";
            ViewBag.URL = "/Service/List";

            return View("../Shared/Redirect");
            //return RedirectToAction("List");
        }