public bool UpdateSystemUserWarehouseMap(SystemUserWarehouseMap data) { bool updated = false; SqlConnection con = new SqlConnection(connectionString); SqlCommand cmd = new SqlCommand("SystemUserWarehouseMap_Update", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@GUID", data.GUID); cmd.Parameters.AddWithValue("@AllowAccess", data.AllowAccess); cmd.Parameters.AddWithValue("@AllowAction", data.AllowAction); try { con.Open(); cmd.ExecuteNonQuery(); updated = true; } catch (Exception e) { string error = e.Message; updated = false; } finally { con.Close(); } return(updated); }
public bool GiveAndTakeAccess(string WarehouseGUID, string SystemUserGUID, string Access) { bool access = false; List <SystemUserWarehouseMap> list = new List <SystemUserWarehouseMap>(); SystemUserWarehouseMap model = new SystemUserWarehouseMap(); list = lstFetch.ExcuteObject <SystemUserWarehouseMap>("[dbo].[SystemUserWarehouseMap_GetAllReal]", true).ToList(); list = list.Where(a => a.SystemUserGUID == SystemUserGUID && a.WarehouseGUID == WarehouseGUID).ToList(); if (list.Count > 0) { model = list.FirstOrDefault(); model.AllowAccess = Convert.ToInt32(Access); model.AllowAction = 1; this.UpdateSystemUserWarehouseMap(model); access = true; } else { model.GUID = Guid.NewGuid().ToString(); model.SystemUserGUID = SystemUserGUID; model.WarehouseGUID = WarehouseGUID; model.AllowAction = 1; model.AllowAccess = Convert.ToInt32(Access); this.AddSystemUserWarehouseMap(model); access = true; } return(access); }