public override bool UpdateData(int id, ref DTO.UserMng.UserProfile dtoItem, out Library.DTO.Notification notification)
        {
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };
            int    number;
            string indexName;

            try
            {
                using (UserMngEntities context = CreateContext())
                {
                    UserProfile dbItem = null;
                    if (id == 0)
                    {
                        dbItem = new UserProfile();
                        context.UserProfile.Add(dbItem);
                        dbItem.CreatedDate = DateTime.Now;
                        dbItem.CreatedBy   = dtoItem.UpdatedBy;
                    }
                    else
                    {
                        dbItem = context.UserProfile.FirstOrDefault(o => o.UserId == id);
                    }

                    if (dbItem == null)
                    {
                        notification.Message = "User not found!";
                        return(false);
                    }
                    else
                    {
                        // check concurrency
                        if (dbItem.ConcurrencyFlag != null && !dbItem.ConcurrencyFlag.SequenceEqual(Convert.FromBase64String(dtoItem.ConcurrencyFlag_String)))
                        {
                            throw new Exception(DALBase.Helper.TEXT_CONCURRENCY_CONFLICT);
                        }
                        converter.DTO2DB(dtoItem, ref dbItem);

                        // remove orphans
                        context.UserPermission.Local.Where(o => o.UserProfile == null).ToList().ForEach(o => context.UserPermission.Remove(o));
                        context.UserFactoryAccess.Local.Where(o => o.UserProfile == null).ToList().ForEach(o => context.UserFactoryAccess.Remove(o));
                        context.SaveChanges();

                        dbItem.UserUD = dbItem.UserId.ToString();
                        context.SaveChanges();

                        // processing image
                        if (dtoItem.PersonalPhoto_HasChange)
                        {
                            dbItem.PersonalPhoto = fwFactory.CreateFilePointer(this._TempFolder, dtoItem.PersonalPhoto_NewFile, dtoItem.PersonalPhoto);
                        }
                        if (dtoItem.SignatureImage_HasChange)
                        {
                            dbItem.SignatureImage = fwFactory.CreateFilePointer(this._TempFolder, dtoItem.SignatureImage_NewFile, dtoItem.SignatureImage);
                        }
                        context.SaveChanges();

                        dtoItem = GetData(dbItem.UserId, out notification).Data;

                        return(true);
                    }
                }
            }
            catch (System.Data.DataException dEx)
            {
                notification.Type = Library.DTO.NotificationType.Error;
                Library.ErrorHelper.DataExceptionParser(dEx, out number, out indexName);
                if (number == 2627)
                {
                    switch (indexName)
                    {
                    case "UserUDUnique":
                        notification.Message = "Duplicate user code";
                        break;

                    default:
                        notification.Message = dEx.Message;
                        break;
                    }
                }
                else
                {
                    notification.Message = dEx.Message;
                }

                return(false);
            }
            catch (Exception ex)
            {
                notification.Type    = Library.DTO.NotificationType.Error;
                notification.Message = ex.Message;
                return(false);
            }
        }