问题描述:

can someone help me with this issue in my project..

i have workers that has different logins and have the same role. i have a customer page that worker can apply for a company's position(grid) with different shift(another grid inside the company's position). when a worker apply on that shift,the row will disappear in the grid.

my problem is.. i want to show the row again when another worker logs in.

how can i do this.. i did it only in one worker only.

here's what i have...

controller:

//to load the data of the grid

public JsonResult LoadCustomerPositionShiftWorkerList(int? clientCusPosId, int? clientId)

{

List<userWorkerCompare> workerDetails = new List<userWorkerCompare>();

GlobalVariables.SiteMapFile = "ClientSiteMapProvider";

MembershipUser membershipUser = Membership.GetUser();

string userId = membershipUser.ProviderUserKey.ToString();

var workerIdList = new List<Int32>();

var customerPositionShiftList = new List<Client_Customer_Position_Shift>();

List<ClientCustomerPositionShiftInfo> clientCustomerPositionShiftList = new List<ClientCustomerPositionShiftInfo>();

var filterList = (from a in db.Worker_Customer_Apply_Shift

where a.LogicalDelete == false && a.Client_Customer_PositionID == clientCusPosId

select a).ToList();

//this is to get workerId

if (Roles.IsUserInRole("Worker"))

{

var listWorker = (from a in db.Workers

where a.LogicalDelete == false

select new

{

a.ID,

a.userId,

a.FirstName,

a.LastName,

a.MiddleName,

a.BirthDate,

a.Gender_LookID,

a.LogicalDelete

}).ToList();

if (listWorker.Count() > 0)

{

foreach (var row in listWorker)

{

var cli = new userWorkerCompare

{

ID = row.ID,

FirstName = row.FirstName,

MiddleName = row.MiddleName,

LastName = row.LastName,

LogicalDelete = row.LogicalDelete,

userId = row.userId.ToString()

};

workerDetails.Add(cli);

}

var workerProfile = (from a in workerDetails

join b in db.Workers

on a.ID equals b.ID

where a.LogicalDelete == false && a.userId == userId

select b).SingleOrDefault();

ViewBag.WorkerProfile = workerProfile;

var workerAvail = (from a in db.Worker_Availability

where a.LogicalDelete == false

&& a.Worker_ID == workerProfile.ID

select a).ToList();

ViewBag.WorkerAvail = workerAvail;

var workerId = (from a in workerDetails

where a.LogicalDelete == false && a.userId == userId

select a.ID).SingleOrDefault();

ViewBag.WorkerId = workerId;

//this is to compare customer position shift from worker availability

if (clientCusPosId.HasValue)

{

customerPositionShiftList = (from a in db.Client_Customer_Position_Shift

where a.LogicalDelete == false && a.Client_Customer_PositionID == clientCusPosId

select a).ToList();

foreach (var row in customerPositionShiftList)

{

var workerList = (from a in db.Worker_Availability

where a.LogicalDelete == false && a.Worker_ID == workerProfile.ID

select a).ToList();

foreach (var Availability in workerList)

{

if (Availability.AvailableDay_LookID == row.Day_LookID || Availability.AvailableDay_LookID == 76 || row.Day_LookID == 76)

{

if (((Availability.StartTime == "Anytime" && Availability.EndTime == "Anytime") || (row.StartTime == "Anytime" && row.EndTime == "Anytime")) ||

(row.StartTime == "Anytime" || row.EndTime == "Anytime") || (Availability.StartTime == "Anytime" || Availability.EndTime == "Anytime"))

{

workerIdList.Add(row.ID);

}

else

{

DateTime availStartTime = Convert.ToDateTime(Availability.StartTime);

DateTime posStartTime = Convert.ToDateTime(row.StartTime);

DateTime availEndTime = Convert.ToDateTime(Availability.EndTime);

DateTime posEndTime = Convert.ToDateTime(row.EndTime);

if ((Availability.StartTime == row.StartTime &&

Availability.EndTime == row.EndTime) || (Availability.StartTime == row.StartTime ||

Availability.EndTime == row.EndTime) || (availStartTime < posStartTime && availEndTime > posEndTime))

{

workerIdList.Add(row.ID);

}

}

}

}

}

}

//to show compared list

var toBeList = (from a in customerPositionShiftList

where a.LogicalDelete == false

select a).ToList();

//after applying this one triggers to hide the row

var setToList =

toBeList.Select(x => x.ID).Except(filterList.Select(y => y.clientCusPosShiftId)).ToList();

var cusWorkList = (from a in db.Client_Customer_Position_Shift

where a.LogicalDelete == false

&& workerIdList.Contains(a.ID)

&& setToList.Contains(a.ID)

select new

{

a.ID,

a.Client_CustomerID,

a.Client_Customer_PositionID,

a.Day_LookID,

a.EndTime,

a.StartTime,

a.LogicalDelete

}).ToList();

if (cusWorkList.Count() > 0)

{

foreach (var row in cusWorkList)

{

ClientCustomerPositionShiftInfo ccpsi = new ClientCustomerPositionShiftInfo

{

ID = row.ID,

ClientID = clientId.HasValue ? clientId.Value : 0,

Client_Customer_PositionID = row.Client_Customer_PositionID,

Client_CustomerID = row.Client_CustomerID,

Day = GetLookupDisplayValById(row.Day_LookID),

StartTime = row.StartTime != "Anytime" ? Convert.ToDateTime(row.StartTime).ToString("hh:mm tt") : row.StartTime.Trim(),

EndTime = row.EndTime != "Anytime" ? Convert.ToDateTime(row.EndTime).ToString("hh:mm tt") : row.EndTime.Trim(),

DayID = (row.Day_LookID)

};

clientCustomerPositionShiftList.Add(ccpsi);

}

}

}

}

return Json(clientCustomerPositionShiftList.ToList().OrderBy(p => p.DayID), JsonRequestBehavior.AllowGet);

}

view/script:

<script type="text/javascript">

$(document).ready(function () {

var comparegrid = $("#positionShiftWorkerComparedGrid").kendoGrid({

scrollable: false,

sortable: true,

pageable: true,

dataSource: {

transport: {

read: {

url: '/Customer/LoadCustomerPositionShiftWorkerList?clientCusId=' + clientCusId + '&clientId=' + clientId + '&clientCusPosId=' + clientCusPosId,

dataType: "json",

type: "POST"

}

},

pageSize: 10

},

rowTemplate: kendo.template($("#positionShiftWorkerComparedTemplate").html().replace('k-alt', '')),

altRowTemplate: kendo.template($("#positionShiftWorkerComparedTemplate").html())

});

});

</script>

thanks!

相关阅读:
Top