public void PropertyScheduleEdit(PropertyViewModel model) { string UserId = BHIP.Model.Helper.Security.GetLoggedInUserID(); PropertyScheduleHold property = new PropertyScheduleHold { BI_EE = model.BI_EE, BuildingValue = model.BuildingValue, City = model.City, ConstructionDate = model.ConstructionDate, ConstructionTypeID = model.ConstructionTypeID, ContentValue = model.ContentValue, DateAdded = model.DateAdded, DateRemoved = model.DateRemoved, EditType = "Edit", FireBurglerID = model.FireBurglerID, LocationAddress = model.LocationAddress, LocationName = model.LocationName, LocationNumber = model.LocationNumber, MemberCoverageID = model.MemberCoverageID, OwnLeaseID = model.OwnLeaseID, PropertyScheduleID = model.PropertyScheduleID, RemodelDate = model.RemodelDate, SquareFoot = model.SquareFoot, StateID = model.StateID, Zip = model.Zip, COI = model.COI, ScheduleStatusID = 2, UserID = UserId }; ContextPerRequest.CurrentData.PropertyScheduleHolds.Add(property); ContextPerRequest.CurrentData.SaveChanges(); }
public void PropertyScheduleDelete(PropertyDeleteViewModel model) { string UserId = BHIP.Model.Helper.Security.GetLoggedInUserID(); var query = (from prop in ContextPerRequest.CurrentData.PropertySchedules where prop.PropertyScheduleID == model.PropertyScheduleID select prop).FirstOrDefault(); PropertyScheduleHold property = new PropertyScheduleHold { BI_EE = query.BI_EE, BuildingValue = query.BuildingValue, City = query.City, ConstructionDate = query.ConstructionDate, ConstructionTypeID = query.ConstructionTypeID, ContentValue = query.ContentValue, DateAdded = query.DateAdded, DateRemoved = model.DateRemoved, EditType = "Delete", FireBurglerID = query.FireBurglerID, LocationAddress = query.LocationAddress, LocationName = query.LocationName, LocationNumber = query.LocationNumber, MemberCoverageID = query.MemberCoverageID, OwnLeaseID = query.OwnLeaseID, PropertyScheduleID = query.PropertyScheduleID, RemodelDate = query.RemodelDate, SquareFoot = query.SquareFoot, StateID = query.StateID, Zip = query.Zip, ScheduleStatusID = 2, UserID = UserId }; ContextPerRequest.CurrentData.PropertyScheduleHolds.Add(property); ContextPerRequest.CurrentData.SaveChanges(); }
public void TransferScheduleRecords(PropertyScheduleHold model) { if (model.EditType == "Edit") { var query = (from property in ContextPerRequest.CurrentData.PropertySchedules where property.PropertyScheduleID == model.PropertyScheduleID select property).FirstOrDefault(); if (query != null) { query.BI_EE = model.BI_EE; query.BuildingValue = model.BuildingValue; query.City = model.City; query.ConstructionDate = model.ConstructionDate; query.ConstructionTypeID = model.ConstructionTypeID; query.ContentValue = model.ContentValue; query.FireBurglerID = model.FireBurglerID; query.LocationAddress = model.LocationAddress; query.LocationName = model.LocationName; query.LocationNumber = model.LocationNumber; query.MemberCoverageID = model.MemberCoverageID; query.OwnLeaseID = model.OwnLeaseID; query.RemodelDate = model.RemodelDate; query.SquareFoot = model.SquareFoot; query.StateID = model.StateID; query.Zip = model.Zip; query.DateAdded = model.DateAdded; query.DateRemoved = model.DateRemoved; ContextPerRequest.CurrentData.SaveChanges(); } } else if (model.EditType == "Add") { PropertySchedule vehicle = new PropertySchedule { BI_EE = model.BI_EE, BuildingValue = model.BuildingValue, City = model.City, ConstructionDate = model.ConstructionDate, ConstructionTypeID = model.ConstructionTypeID, ContentValue = model.ContentValue, DateAdded = model.DateAdded, FireBurglerID = model.FireBurglerID, LocationAddress = model.LocationAddress, LocationName = model.LocationName, LocationNumber = model.LocationNumber, MemberCoverageID = model.MemberCoverageID, OwnLeaseID = model.OwnLeaseID, RemodelDate = model.RemodelDate, SquareFoot = model.SquareFoot, StateID = model.StateID, Zip = model.Zip }; ContextPerRequest.CurrentData.PropertySchedules.Add(vehicle); ContextPerRequest.CurrentData.SaveChanges(); } else if (model.EditType == "Delete") { var deleteQuery = (from property in ContextPerRequest.CurrentData.PropertySchedules where property.PropertyScheduleID == model.PropertyScheduleID select property).FirstOrDefault(); if (deleteQuery != null) { deleteQuery.DateRemoved = model.DateRemoved; ContextPerRequest.CurrentData.SaveChanges(); } } }
public EmailProperty PropertyPendingApprove(string scheduleIds) { EmailProperty emailModel = new EmailProperty(); emailModel.PropertyCOIList = new List <SendingProperty>(); emailModel.PropertyAddList = new List <SendingProperty>(); emailModel.PropertyDeleteList = new List <SendingProperty>(); emailModel.PropertyEditList = new List <SendingProperty>(); List <string> listScheduleID = new List <string>(); listScheduleID = scheduleIds.Split(',').ToList(); foreach (var item in listScheduleID) { int scheduleHoldID = Convert.ToInt32(item.ToString()); var query = (from property in ContextPerRequest.CurrentData.PropertyScheduleHolds join construct in ContextPerRequest.CurrentData.ConstructionTypes on property.ConstructionTypeID equals construct.ConstTypeID join fire in ContextPerRequest.CurrentData.FireBurglars on property.FireBurglerID equals fire.FireBurglarID join own in ContextPerRequest.CurrentData.OwnLeases on property.OwnLeaseID equals own.OwnLeaseID join state in ContextPerRequest.CurrentData.States on property.StateID equals state.StateId where property.PropertyScheduleHoldID == scheduleHoldID select new PropertyScheduleHoldViewModel { BI_EE = property.BI_EE, BuildingValue = property.BuildingValue, City = property.City, ConstructionDate = property.ConstructionDate, ConstructionName = construct.Description, ContentValue = property.ContentValue, DateAdded = property.DateAdded, DateRemoved = property.DateRemoved, FireName = fire.Description, LocationAddress = property.LocationAddress, LocationName = property.LocationName, LocationNumber = property.LocationNumber, MemberCoverageID = property.MemberCoverageID, OwnLeaseName = own.Description, PropertyScheduleHoldID = property.PropertyScheduleHoldID, PropertyScheduleID = property.PropertyScheduleID, RemodelDate = property.RemodelDate, SquareFoot = property.SquareFoot, StateName = state.Name, Zip = property.Zip, EditType = property.EditType, COI = property.COI, ConstructionTypeID = property.ConstructionTypeID ?? 0, FireBurglerID = property.FireBurglerID ?? 0, OwnLeaseID = property.OwnLeaseID ?? 0, ScheduleStatusID = property.ScheduleStatusID, StateID = property.StateID ?? 0 }).FirstOrDefault(); var queryUpdate = (from prop in ContextPerRequest.CurrentData.PropertyScheduleHolds where prop.PropertyScheduleHoldID == scheduleHoldID select prop).FirstOrDefault <PropertyScheduleHold>(); if (query != null && queryUpdate != null) { int statusId = query.ScheduleStatusID; if (statusId == 2 && query.COI == true) // pending and COI is checked. { SendingProperty coiModel = new SendingProperty(); coiModel.Address = query.LocationAddress; coiModel.City = query.City; coiModel.PropertyName = query.LocationName; coiModel.Zip = query.Zip; coiModel.TypeOfConstruction = query.ConstructionName; coiModel.Cost = string.Format("{0:C}", query.SquareFoot == 0 ? 0 : (query.BuildingValue + query.ContentValue) / query.SquareFoot); coiModel.DateAdded = (query.DateAdded.HasValue == true ? Convert.ToDateTime(query.DateAdded).ToShortDateString() : string.Empty); coiModel.DateContruction = (query.ConstructionDate.HasValue == true ? Convert.ToDateTime(query.ConstructionDate).ToShortDateString() : string.Empty); coiModel.FireBurglar = query.FireName; coiModel.OwnLease = query.OwnLeaseName; coiModel.SquareFootage = query.SquareFoot.ToString(); coiModel.State = query.StateName; emailModel.PropertyCOIList.Add(coiModel); queryUpdate.ScheduleStatusID = 3; ContextPerRequest.CurrentData.SaveChanges(); } if (statusId == 3) { queryUpdate.ScheduleStatusID = 5; ContextPerRequest.CurrentData.SaveChanges(); } else if (statusId == 2) // pending and no COI { if (query.EditType == "Add") { SendingProperty addModel = new SendingProperty(); addModel.Address = query.LocationAddress; addModel.City = query.City; addModel.PropertyName = query.LocationName; addModel.Zip = query.Zip; addModel.TypeOfConstruction = query.ConstructionName; addModel.Cost = string.Format("{0:C}", query.SquareFoot == 0 ? 0 : (query.BuildingValue + query.ContentValue) / query.SquareFoot); addModel.DateAdded = (query.DateAdded.HasValue == true ? Convert.ToDateTime(query.DateAdded).ToShortDateString() : string.Empty); addModel.DateContruction = (query.ConstructionDate.HasValue == true ? Convert.ToDateTime(query.ConstructionDate).ToShortDateString() : string.Empty); addModel.FireBurglar = query.FireName; addModel.OwnLease = query.OwnLeaseName; addModel.SquareFootage = query.SquareFoot.ToString(); addModel.BuildingValue = string.Format("{0:C}", query.BuildingValue); addModel.ContentValue = string.Format("{0:C}", query.ContentValue); addModel.State = query.StateName; emailModel.PropertyAddList.Add(addModel); } else if (query.EditType == "Edit" && query.COI) { SendingProperty editModel = new SendingProperty(); editModel.Address = query.LocationAddress; editModel.City = query.City; editModel.PropertyName = query.LocationName; editModel.Zip = query.Zip; editModel.TypeOfConstruction = query.ConstructionName; editModel.Cost = string.Format("{0:C}", query.SquareFoot == 0 ? 0 : (query.BuildingValue + query.ContentValue) / query.SquareFoot); editModel.DateAdded = (query.DateAdded.HasValue == true ? Convert.ToDateTime(query.DateAdded).ToShortDateString() : string.Empty); editModel.DateContruction = (query.ConstructionDate.HasValue == true ? Convert.ToDateTime(query.ConstructionDate).ToShortDateString() : string.Empty); editModel.FireBurglar = query.FireName; editModel.OwnLease = query.OwnLeaseName; editModel.SquareFootage = query.SquareFoot.ToString(); editModel.State = query.StateName; editModel.BuildingValue = string.Format("{0:C}", query.BuildingValue); editModel.ContentValue = string.Format("{0:C}", query.ContentValue); emailModel.PropertyEditList.Add(editModel); } else if (query.EditType == "Delete") { SendingProperty deleteModel = new SendingProperty(); deleteModel.Address = query.LocationAddress; deleteModel.City = query.City; deleteModel.PropertyName = query.LocationName; deleteModel.Zip = query.Zip; deleteModel.TypeOfConstruction = query.ConstructionName; deleteModel.Cost = string.Format("{0:C}", query.SquareFoot == 0 ? 0 : (query.BuildingValue + query.ContentValue) / query.SquareFoot); deleteModel.DateAdded = (query.DateAdded.HasValue == true ? Convert.ToDateTime(query.DateAdded).ToShortDateString() : string.Empty); deleteModel.DateContruction = (query.ConstructionDate.HasValue == true ? Convert.ToDateTime(query.ConstructionDate).ToShortDateString() : string.Empty); deleteModel.FireBurglar = query.FireName; deleteModel.OwnLease = query.OwnLeaseName; deleteModel.SquareFootage = query.SquareFoot.ToString(); deleteModel.State = query.StateName; deleteModel.BuildingValue = string.Format("{0:C}", query.BuildingValue); deleteModel.ContentValue = string.Format("{0:C}", query.ContentValue); deleteModel.DateRemoved = (query.DateRemoved.HasValue == true ? Convert.ToDateTime(query.DateRemoved).ToShortDateString() : string.Empty); emailModel.PropertyDeleteList.Add(deleteModel); } PropertyScheduleHold model = new PropertyScheduleHold { BI_EE = query.BI_EE, BuildingValue = query.BuildingValue, City = query.City, COI = query.COI, ConstructionDate = query.ConstructionDate, ConstructionTypeID = query.ConstructionTypeID, ContentValue = query.ContentValue, DateAdded = query.DateAdded, DateRemoved = query.DateRemoved, EditType = query.EditType, FireBurglerID = query.FireBurglerID, LocationAddress = query.LocationAddress, LocationName = query.LocationName, LocationNumber = query.LocationNumber, MemberCoverageID = query.MemberCoverageID, OwnLeaseID = query.OwnLeaseID, PropertyScheduleID = query.PropertyScheduleID, RemodelDate = query.RemodelDate, ScheduleStatusID = query.ScheduleStatusID, SquareFoot = query.SquareFoot, StateID = query.StateID, Zip = query.Zip }; // need to transfer records. TransferScheduleRecords(model); if (queryUpdate.ScheduleStatusID != 3) { queryUpdate.ScheduleStatusID = 5; } ContextPerRequest.CurrentData.SaveChanges(); } } } return(emailModel); }