/// <summary> /// Update the collectionMissed data to the CollectionMissed Table /// </summary> /// <param name="collectionMissed"></param> /// <returns> /// Return DB_STATUS /// </returns> public Constants.DB_STATUS Update(CollectionMissed collectionMissed) { Constants.DB_STATUS status = Constants.DB_STATUS.UNKNOWN; try { collectionMissedObj = inventory.CollectionMisseds.Where(c => c.Id == collectionMissed.Id).First(); if (collectionMissedObj != null) { //get the department and employee object by checking Id from collectionMissed table departmentObj = inventory.Departments.Where(d => d.Id == collectionMissed.Department.Id).First(); Employee createdBy = inventory.Employees.Where(e => e.Id == collectionMissed.CreatedBy.Id).First(); collectionMissedObj.Id = collectionMissed.Id; collectionMissedObj.Department = departmentObj; collectionMissedObj.CreatedBy = createdBy; collectionMissedObj.CreatedDate = collectionMissed.CreatedDate; inventory.SaveChanges(); status = Constants.DB_STATUS.SUCCESSFULL; } } catch (Exception e) { status = Constants.DB_STATUS.FAILED; } return(status); }
/// <summary> /// Get CollectionMissed from CollectionMissed Table /// </summary> /// <param name="collectionMissed"></param> /// <returns> /// CollectionMissed Object /// </returns> public CollectionMissed GetCollectionMissed(CollectionMissed collectionMissed) { try { //Get the collectionMissed Object by collectionMissed Parameter's Id collectionMissedObj = inventory.CollectionMisseds.Where(c => c.Id == collectionMissed.Id).First(); } catch (Exception e) { collectionMissedObj = null; } return(collectionMissedObj); }
/// <summary> /// Logically delete the status of collectionMissed table /// </summary> /// <param name="collectionMissed"></param> /// <returns> /// Return the DB_STATUS /// </returns> public Constants.DB_STATUS Delete(CollectionMissed collectionMissed) { Constants.DB_STATUS status = Constants.DB_STATUS.UNKNOWN; try { collectionMissedObj = inventory.CollectionMisseds.Where(c => c.Id == collectionMissed.Id).First(); collectionMissedObj.Status = 2; inventory.SaveChanges(); status = Constants.DB_STATUS.SUCCESSFULL; } catch (Exception e) { status = Constants.DB_STATUS.FAILED; } return(status); }
/// <summary> /// Insert the collectionMissed data to the CollectionMissed Table /// </summary> /// <param name="newCollectionMissed"></param> /// <returns> /// Return DB_STATUS /// </returns> public Constants.DB_STATUS Insert(CollectionMissed newCollectionMissed) { Constants.DB_STATUS status = Constants.DB_STATUS.UNKNOWN; try { inventory.AddToCollectionMisseds(newCollectionMissed); inventory.SaveChanges(); status = Constants.DB_STATUS.SUCCESSFULL; } catch (Exception e) { status = Constants.DB_STATUS.FAILED; } return(status); }