Example #1
0
        public Message Assign(AssetMaster objUI)
        {
            Message msg = null;
            try
            {
                AssetMaster objDb = GetById(objUI.ID.ToString());

                if (objDb != null)
                {
                    Assign(objUI, objDb, ref msg);
                }
                else
                {
                    msg = new Message(MessageConstants.E0040, MessageType.Error, "Asset '" + objUI.ID + "'");
                }
            }
            catch (Exception)
            {
                msg = new Message(MessageConstants.E0007, MessageType.Error);
            }

            return msg;
        }
Example #2
0
        private void Update(AssetMaster objUI, AssetMaster objDb, ref Message msg)
        {
            if (!IsDBChanged(objUI, objDb))
            {
                if (!IsDublicateAssetId(objUI))
                {
                    objDb.AssetID = objUI.AssetID;
                    objDb.CategoryId = objUI.CategoryId;
                    objDb.StatusId = objUI.StatusId;
                    objDb.EmployeeId = (String.IsNullOrEmpty(objUI.EmployeeId)) ? null : objUI.EmployeeId;
                    objDb.Remark = objUI.Remark;
                    objDb.IsActive = objUI.IsActive;
                    objDb.UpdateDate = DateTime.Now;
                    objDb.UpdatedBy = objUI.UpdatedBy;

                    dbContext.SubmitChanges();
                    msg = new Message(MessageConstants.I0001, MessageType.Info, "Asset Master '" + objUI.AssetID + "'", "updated");
                }
                else
                {
                    msg = new Message(MessageConstants.E0020, MessageType.Error, "'" + objUI.AssetID + "'", "Asset Property");
                }
            }
            else
            {
                msg = new Message(MessageConstants.E0025, MessageType.Error, "Asset Master'" + objDb.AssetID + "'");
            }
        }
Example #3
0
        private void ReAssign(AssetMaster objUI, AssetMaster objDb, ref Message msg)
        {
            if (IsDBChanged(objUI, objDb))
            {
                if (!IsDublicateAssetId(objUI))
                {
                    objDb.AssetID = objDb.AssetID;
                    objDb.CategoryId = objDb.CategoryId;
                    objDb.StatusId = Constants.ASSIGN_ASSET_AVAILABLE_STATUS;
                    objDb.EmployeeId = Constants.ASSIGN_ASSET_EMPLOYEE_NULL;
                    objDb.Remark = objDb.Remark;
                    objDb.IsActive = objDb.IsActive;
                    objDb.UpdateDate = DateTime.Now;
                    objDb.UpdatedBy = objDb.UpdatedBy;

                    dbContext.SubmitChanges();
                }
            }
        }
Example #4
0
 private bool IsDublicateAssetId(AssetMaster objUI)
 {
     bool isDublicateName = true;
     AssetMaster dublicateName = dbContext.AssetMasters.Where(a => a.AssetID.Equals(objUI.AssetID) && a.DeleteFlag == false).FirstOrDefault<AssetMaster>();
     if (dublicateName == null || dublicateName.ID == objUI.ID)
     {
         isDublicateName = false;
     }
     return isDublicateName;
 }
Example #5
0
 private bool IsDBChanged(AssetMaster objUI, AssetMaster objDb)
 {
     bool isChannged = true;
     if (objDb.UpdateDate.ToString() == objUI.UpdateDate.ToString())
     {
         isChannged = false;
     }
     return isChannged;
 }
Example #6
0
        private void Delete(AssetMaster objUI)
        {
            if (objUI != null)
            {
                // Get current group in dbContext
                AssetMaster objDb = GetById(objUI.ID.ToString());
                if (objDb != null)
                {
                    // Set delete info
                    objDb.DeleteFlag = true;
                    objDb.UpdateDate = DateTime.Now;
                    objDb.UpdatedBy = objUI.UpdatedBy;
                    // Submit changes to dbContext
                    dbContext.SubmitChanges();

                }
            }
        }
Example #7
0
        private void Assign(AssetMaster objUI, AssetMaster objDb, ref Message msg)
        {
            if (IsDBChanged(objUI, objDb))
            {
                if (!IsDublicateAssetId(objUI))
                {
                    objDb.AssetID = objDb.AssetID;
                    objDb.CategoryId = objDb.CategoryId;
                    objDb.StatusId = Constants.ASSIGN_ASSET_INUSE_STATUS;
                    objDb.EmployeeId = (String.IsNullOrEmpty(objUI.EmployeeId)) ? null : objUI.EmployeeId; ;
                    objDb.Remark = objDb.Remark;
                    objDb.IsActive = objDb.IsActive;
                    objDb.UpdateDate = DateTime.Now;
                    objDb.UpdatedBy = objDb.UpdatedBy;

                    dbContext.SubmitChanges();
                }
            }
        }
Example #8
0
 public Message Insert(AssetMaster objUI)
 {
     Message msg = null;
     try
     {
         if (!IsDublicateAssetId(objUI))
         {
             dbContext.AssetMasters.InsertOnSubmit(objUI);
             dbContext.SubmitChanges();
             msg = new Message(MessageConstants.I0001, MessageType.Info, "Asset Master '" + objUI.AssetID + "'", "added");
         }
         else
         {
             msg = new Message(MessageConstants.E0020, MessageType.Error, "Name '" + objUI.AssetID + "'", "Asset Master");
         }
     }
     catch (Exception)
     {
         msg = new Message(MessageConstants.E0007, MessageType.Error);
     }
     return msg;
 }